dat-ecosystem-archive / dat-node

Node module for creating dat compatible tools on file systems [ DEPRECATED - More info on active projects and modules at https://dat-ecosystem.org/ ]
https://dat.foundation
MIT License
502 stars 63 forks source link

Dat Close Assertion #217

Open eu1444 opened 6 years ago

eu1444 commented 6 years ago

I am reporting:

Bug Report

Expected behavior

I have some code that opens multiple Dats and then closes them all. The expected behavior is that all of the Dats open and then close without error.

https://gist.github.com/mistersdevelopment/2cddb3760e48de701e602933f3193a40

Actual behavior

The code intermittently asserts in libuv. I realize this may be a libuv issue but it could be how Dat is making use of libuv as well.

node: ../deps/uv/src/unix/udp.c:67: uv__udp_finish_close: Assertion `!uv__io_active(&handle->io_watcher, 0x001 | 0x004)' failed.

The assertion is here: https://github.com/libuv/libuv/blob/619937c783a05b51fba95cc9a62543deeffe5fa7/src/unix/udp.c#L67

Debug Logs

node libuv-assert.js 
  dat-node archive ready. version: 0 +0ms
  dat-node archive ready. version: 0 +17ms
  dat-node archive ready. version: 0 +3ms
  dat-node Replication error: First shared hypercore must be the same +0ms
  dat-node Stream close +2ms
  dat-node Replication stream ended +5ms
  dat-node Replication error: First shared hypercore must be the same +680ms
  dat-node Stream close +1ms
  dat-node Replication stream ended +1ms
Created Dat "a9e3b0c7acef0417d2840c75ff38eb92b33effbe5843b65f7b7f9db6fcb70a71" with storage "dat-2"
Created Dat "5be8f49de14e6876374207e00260045b6c892cead878f735543bc90c2cc673ca" with storage "dat-0"
Created Dat "2b69b2062aee49b675880f821c5dc80b9f4a3b5adbda0d3f5e830dc1a45c3426" with storage "dat-1"
Destroying Dat "5be8f49de14e6876374207e00260045b6c892cead878f735543bc90c2cc673ca"
  dat-node leaveNetwork() +7s
Destroying Dat "2b69b2062aee49b675880f821c5dc80b9f4a3b5adbda0d3f5e830dc1a45c3426"
  dat-node leaveNetwork() +8ms
Destroying Dat "a9e3b0c7acef0417d2840c75ff38eb92b33effbe5843b65f7b7f9db6fcb70a71"
  dat-node leaveNetwork() +4ms
node: ../deps/uv/src/unix/udp.c:67: uv__udp_finish_close: Assertion `!uv__io_active(&handle->io_watcher, 0x001 | 0x004)' failed.

Thanks!

JoshuaBrookover commented 6 years ago

Also having this problem on OS X. Same node version.

tullrich commented 6 years ago

This gist appears to work on my Windows 10 machine with node version 8.7.0.

I tried it on Linux (4.17.6) Node version 8.0.0 and the gist again worked. However, if I increase the number of simultaneous archives it eventually fails with 8 open dats with the following error:

Created Dat "c70c9c0392915ddbad26301caca1c818af2915273d9d17e5f7875d58ff9e08fe" with storage "dat-1"
Created Dat "bfd6db5a09a6b6e2373b3f6e78a6505795e7a6f386356cb5d8f1a15287d665ce" with storage "dat-5"
Created Dat "4b0b40fc5d0be3c95196044a5f2e8e2d0468e93fce6d6538c0158493a5bb8e49" with storage "dat-4"
Created Dat "941cd1683df6023ea29dc4e9242aafa35cd8a014682699b06f744d5bef3aad25" with storage "dat-2"
Created Dat "f2c644bb6c223f4e9e8a5d88b1fded44259e0ffa03ad28d6dbdaad790516f56f" with storage "dat-6"
Created Dat "a83d642efcc4ddee6c3f97d3024dccbfe120a5dd6e7f91a517193847d964e7fb" with storage "dat-7"
Created Dat "ffc7258e515a58da7c949c61084554c892ad086388b9bc95f8052a18b9d9b9dd" with storage "dat-0"
Error: No nodes to query
    at RPC.queryAll (/projects/test/node_modules/k-rpc/index.js:123:27)
    at DHT.announce (/projects/test/node_modules/bittorrent-dht/client.js:423:13)
    at /projects/test/node_modules/bittorrent-dht/client.js:432:10
    at done (/projects/test/node_modules/bittorrent-dht/client.js:673:5)
    at done (/projects/test/node_modules/k-rpc/index.js:240:5)
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickCallback (internal/process/next_tick.js:161:9)

Not sure if it is related.

joehand commented 6 years ago

Thanks, we've seen similar issues but never been able to pin it down in the udp library. @mafintosh any ideas here?