Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

feat: wasm dev server #26

Merged
merged 4 commits into from
Feb 15, 2022
Merged

feat: wasm dev server #26

merged 4 commits into from
Feb 15, 2022

Conversation

tchardin
Copy link
Contributor

Building wasm:

  • Run wasm-pack build --target web --out-dir web/src/wasm -- --features browser --no-default-features. This will make sure the right JS files are generated directly in the JS source directory.
  • You will still need to move /web/src/wasm/pop_bg.wasm to /web/public/pop_bg.wasm for it to load properly as it is served separately.
  • To run the web server open a terminal into /web and run npm run start then open http://localhost:8000 in an incognito window (helps register a new service worker each time otherwise you will be running the previous service worker when reloading the page and changes won't take effect).
  • Copy the peer multiaddress (/p2p/) and root CID. You can run it against a pop and if everything works you can retrieve the content for that CID into memory.

Blockers:

  • Currently getting an error message when calling request: Failed to create executor thread pool: Error { kind: Unsupported, message: "operation not supported on this platform" }. Not sure what is causing it, I wasn't aware of a thread pool usage anywhere.
  • I haven't found a way to keep an instance of the swarm and call multiple requests on it from the service worker handler. See Unable to use async functions on instance methods rustwasm/wasm-bindgen#1858 for more context.

@alexander-camuto
Copy link
Collaborator

for reference should pass an executor to the swarm that is compatible with wasm. For instance:

let mut swarm = SwarmBuilder::new(transport, behaviour, local_peer_id)
            .executor(Box::new(|fut| {
                wasm_bindgen_futures::spawn_local(fut);
            }))
            .build();

@tchardin tchardin changed the title feat: resolvers feat: wasm dev server Feb 15, 2022
@tchardin tchardin merged commit fcb4ff3 into main Feb 15, 2022
@tchardin tchardin deleted the tc/resolvers branch February 15, 2022 16:01
@alexander-camuto
Copy link
Collaborator

delete

 let mut yamux_config = yamux::YamuxConfig::default();
        yamux_config.set_max_buffer_size(16 * 1024 * 1024);
        yamux_config.set_receive_window_size(16 * 1024 * 1024);
        core::upgrade::SelectUpgrade::new(yamux_config, mplex_config)

as SelectUpgrade seems to hang forever in the browser. Multiplexer should just be the default mplex::MplexConfig::new()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants