-
Notifications
You must be signed in to change notification settings - Fork 51
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As explained in the CHANGELOG, this PR allows running smoldot in the background by passing a port to the new
portToWorker
field inClientOptions
.You can find an example in
demo/demo.mjs
anddemo/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 callconnectToRemoteInstance
instead ofstartLocalInstance
.The
run
function, to which the other side of the port must be provided, can be imported fromsmoldot-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 toraw-instance.ts
, so that only plain field need to be passed around.