-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Arraybuffer at index 0 is already detached #3480
Comments
@icidasset thanks for tackling this issue. While dropping empty I think we need to get to the bottom of this, meaning understand how do we end up passing same I understand it can be really hard to figure out the origin of the issue, but I think there is a viable option of doing so by doing following:
I think that would help detect the source of the the problem. I'm happy to do a peer session or something if that would help. Otherwise some automated example with a source code that I can modify would be a very helpful. |
@Gozala Yeah that makes total sense. I'll see if I can implement it like that 👌 Thanks! I guess SharedArrayBuffer is not really applicable here, because then we'd need new instances of |
@Gozala Also, I agree, I would like to figure this out as well. I guess a buffer only becomes detached by transferring it via What I found so far: |
That is my understanding as well.
Question is where is that buffer coming from. Because whatever allocates it seems to retain & reuse it. I imagine there could be few reasons for this to happen:
I think figuring out which one is it will allow us to fix it. Maybe storing not just stack traces but also byte offsets and copies will help eliminate or validate 2nd possibility |
This one would actually explain the former issue that you’ve fixed by using sets. However in this case it appears to span across multiple posts, which makes me think it’s more likely to be a 3rd or 1st case. |
I also think it something with the usage pattern, because I have not encountered this problem while serving full sites in the service worker example. |
The issue always occurs with
More notes:
This last note makes me think that problem is definitely not in I'm so confused 😅 Anyhow, digging further, learning a lot about js-ipfs internals here 😂
Yeah for sure, our filesystem implementation is quite a complex use-case I imagine. |
@Gozala I think I figured it out. I think there might be a "concurrency" issue here if I call |
I got around the problem by pinning the used DAG structures. Our library was supposed to do this anyway, but we had a Besides that, I think the above ☝️ is the cause of the problem. Couldn't find anything else that seemed related. |
Version:
ipfs-message-port-server v0.4.3
js-ipfs v0.52.3
Platform:
Darwin Kernel Version 20.1.0
Firefox 84.0.2
Opera 73
Subsystem:
js-ipfs/packages/ipfs-message-port-server/src/server.js
Line 208 in 6b207d7
Severity:
Critical
Description:
We've implemented a filesystem on top of IPFS, which is a mix of DAG PB and DAG CBOR nodes. IPFS is loaded using
ipfs-message-port-client
through an iframe, which then loadsipfs-message-port-server
andjs-ipfs
.I make a bunch of concurrent changes to the file system, resulting in several
dag.put
calls. And it's somewhere here I suspect the error originates from.Steps to reproduce the error:
Hard to reproduce, feels like a concurrency error 🤔
You can try it at https://nightly.diffuse.sh/
→ Login with Fission
→ Add some content (add music, mark some stuff as favourite, make a playlist)
→ Export
→ Import
→ ... wait a minute or so ...
Moving forward
Ok so, I'm working on a PR to fix this, but I don't know how to proceed exactly. How does the ArrayBuffer become detached exactly? Does it become detached if you put in the transfer list of a MessagePort? Should we make a copy of the ArrayBuffer, or should we ignore it? 🤔
The text was updated successfully, but these errors were encountered: