Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running an instance in the background #529

Merged
merged 24 commits into from
May 5, 2023
Merged

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented May 5, 2023

As explained in the CHANGELOG, this PR allows running smoldot in the background by passing a port to the new portToWorker field in ClientOptions.

You can find an example in demo/demo.mjs and demo/demo-worker.mjs.
I've also tested this in the browser to make sure that it works. I didn't test WebRTC due to no WebRTC server being easily available.

I wanted to try Deno, but I can't even make a worker start at all whatsoever, smoldot or not. It's very hard to debug because it's not clear if I'm even supposed to see what the worker prints on the console, and for example if I pass a wrong file name for the worker I don't get any error and execution just continues. Overall just have no idea what's wrong and am getting no feedback from Deno.

If the portToWorker field is present, the client will call connectToRemoteInstance instead of startLocalInstance.

The run function, to which the other side of the port must be provided, can be imported from smoldot-light/worker.
It is not in the same module as the rest of the API, as otherwise we might include the Wasm binary code from the worker as well, meaning that we would end up downloading it twice.

As part of this PR, the parseMultiaddr function has been moved to raw-instance.ts, so that only plain field need to be passed around.

@tomaka tomaka added this pull request to the merge queue May 5, 2023
Merged via the queue into smol-dot:main with commit f3c0753 May 5, 2023
@tomaka tomaka deleted the remote-inst branch May 5, 2023 11:11
tomaka added a commit to tomaka/smoldot that referenced this pull request May 5, 2023
tomaka added a commit that referenced this pull request May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant