-
Notifications
You must be signed in to change notification settings - Fork 105
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
Halt when accessing CID served on a nodejs helia node from a browser helia node #229
Comments
Thanks for submitting this detailed issue @bellbind! @achingbrain I think this another example of a locking, initially described here: #99, I never got around reproducing the test case as it would lock the test runner too. I believe the underlying cause is the same.
I think at that point it's in the store, so it's serviceable right away. |
On my manual tracing, the halt point of Digging into await calls, difference between
I added
Trace of
Trace of
|
I found
|
After updated helia-2.0.1, the helia node on nodejs cannot access with cid served by the helia node on browser (run on node-20.5.1 of m1mac). On
|
can i take this? |
@pravintargaryen |
@pravintargaryen @acul71, either of you can feel free to take this and submit a PR. |
also relevant here is libp2p/js-libp2p#2581 |
FYI i through the code from the gist onto a repo: https://github.com/SgtPooki/helia-repro-cid-retrieve-halt |
I can't run this repro case, even from @SgtPooki's update above. After running % npm run success
> success
> node case-success.mjs
[middle info URL] http://localhost:56560/
[peerId of middle] 12D3KooWJY9WQsUbUTomjTawopctJWvcv2uQsDNFo8TSp1zDSBfh
[peerId on nodejs] 12D3KooWEkrtAob432HiR7ueT8kS3sErwkhU543d7Cnxd9TbGntS
[page server url] http://localhost:56565/index.html
(node:44531) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
node:internal/process/esm_loader:34
internalBinding('errors').triggerUncaughtException(
^
page.evaluate: TypeError: Failed to fetch dynamically imported module: http://localhost:56565/browser.js
at /Users/alex/Documents/Workspaces/SgtPooki/helia-repro-cid-retrieve-halt/case-success.mjs:32:28
Node.js v20.12.2
Edit: Not convinced by this now. @bellbind can you please help me with running your repro case? |
I think what's happening here is that the publishing node is missing a provide step. I've put a demo repo together here that shows how retrieval in browsers works and discusses the caveats in making it work given the state of the Amino DHT today: https://github.com/achingbrain/helia-browser-retrieval It's publishing the block from node and resolving it from a browser, though you could to it the other way round if the browser is dialable from node (e.g. it's listening on a WebRTC address). Obviously if the browser goes offline (user navigates away from the page) it can't serve the bytes any more so it's not very common to do it that way round. Back to the repro though. The "halt" happens at this line because there's no abort signal passed in, so the block goes into the want list, the node fails to find any providers so waits in case it ambiently bumps into a peer that happens to have the block you are after. Instead you should do something like: const stat = await ctx.nodefs.stat(cid, {
signal: AbortSignal.timeout(10000)
}); On the working group call we've previously talked about the routing throwing if it can't find providers, though you'd probably still want a signal in case the routing was very slow reaching that conclusion. Anyway please take a look at the example repo linked to above. |
There are 3 helia nodes that are:
nodejs
: served pinned content of the CIDcreateHelia()
browser
: accessing with the CIDchromium
page ofplaywright
esbuild
from localnode_modules
middle
: connected from bothnodejs
andbrowser
helia nodesnodejs
connectsmiddle
withnodejs.libp2p.dialProtocol(middle.libp2p.getMultiaddrs()[0], nodejs.libp2p.getProtocols())
browser
connects withbootstrap()
config thatlist
is onlymiddle.libp2p.getMultiaddrs()
I tried to resolve content data of a
cid
served on nodejs helia nodes from browser helia nodes.But browser helia nodes halt when
unixfs(browser).stat(cid)
orunixfs(browser).cat(cid)
.(
libp2p.contentRouting.findProviders(cid)
can resolve peerId and multiaddrs of the nodejs helia node)It is success that accessing CID from nodejs to browser.
And after accessed from a nodejs node to a browser node, it can access CID from same browser node to same nodejs node.
The complete codes are in https://gist.github.com/bellbind/5565c22255ae87a3c8e9948b467ee894 :
case-halt.mjs
: halting case that resolve cid from browser to nodejscase-success.mjs
: successed case that resolved other cid from nodejs to browser before resolving from browser to nodejsother files:
nodejs.js
andbrowser.js
: code of creating and connecting helia nodesmiddle
withhttp
servernpm-libs.js
: source ofnpm-browser.js
foresbuild
(complete command line options inpackage.json
)index.html
:importmap
only empty html file for loadingplaywright
pageshttp-server
package to serve thisindex.html
and the builtnpm-browser.js
byhttp:
URLspackage.json
: minimal dependencies and esbuild command lineMy environment is node-v20.5.1-darwin-arm64.tar.gz on M1 macbook air.
The text was updated successfully, but these errors were encountered: