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

Cannot call write after a stream was destroyed #13

Closed
alanshaw opened this issue May 21, 2019 · 1 comment · Fixed by ipfs/js-ipfs#2245
Closed

Cannot call write after a stream was destroyed #13

alanshaw opened this issue May 21, 2019 · 1 comment · Fixed by ipfs/js-ipfs#2245

Comments

@alanshaw
Copy link
Member

Currently crashing ipfs daemon:

  libp2p:conn:out:QmRRGVzV successfully dialed QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +235ms
  libp2p:conn:out:QmRRGVzV selecting crypto /secio/1.0.0 to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +1ms
  libp2p:secio 1. propose - start +1m
  libp2p:secio 1. propose - writing proposal +0ms
  libp2p:secio 1. propose - reading proposal <Buffer 0a 10 c6 73 16 1b b7 87 ab 7f f5 a7 ca 3c b6 c4 32 d3 12 ab 02 08 00 12 a6 02 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 0f 00 ... 330 more bytes> +4ms
  libp2p:secio 1.1 identify +60s
  libp2p:secio 1.1 identify - QmRRGVzVMSss6LjhTFZuU4MA5i52ZWca5vPbKhFaPuu88B - identified remote peer as QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +3ms
  libp2p:secio 1.2 selection +0ms
  libp2p:secio 1. propose - finish +5ms
  libp2p:secio 2. exchange - start +60s
  libp2p:secio 2. exchange - writing exchange +0ms
  libp2p:secio 2. exchange - reading exchange +73ms
  libp2p:secio 2.1. verify +75ms
  libp2p:secio 2.1. verify - signature verified +0ms
  libp2p:secio 2.2. keys +0ms
  libp2p:secio 2.3. mac + cipher +1ms
  libp2p:secio 2. exchange - finish +1ms
  libp2p:secio 3. finish - start +60s
  libp2p:secio 3. finish - finish +3ms
  libp2p:conn:out:QmRRGVzV successfully encrypted connection to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +163ms
  libp2p:conn:out:QmRRGVzV upgrading connection to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:conn:out:QmRRGVzV selecting /mplex/6.7.0 +72ms
  libp2p:conn:out:QmRRGVzV successfully muxed connection to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +75ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +547ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial starting next dial to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial stopping the queue for QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:switch:dial stopping dial queue to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:conn:out:QmRRGVzV created new stream to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +1ms
  libp2p:conn:out:QmRRGVzV new stream created via muxer to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:conn:out:QmRRGVzV new stream created via muxer to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +1ms
  libp2p:conn:out:QmRRGVzV new stream created via muxer to QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +1ms
  libp2p:switch:protocol-muxer registering handler with protocol /libp2p/circuit/relay/0.1.0 +20s
  libp2p-mplex:muxer:error receiver stream errored channel destroyed! +60s
NodeError: Cannot call write after a stream was destroyed
    at doWrite (/Users/alan/.iim/dists/js-ipfs@0.36.0-rc.0/node_modules/readable-stream/lib/_stream_writable.js:405:38)
    at writeOrBuffer (/Users/alan/.iim/dists/js-ipfs@0.36.0-rc.0/node_modules/readable-stream/lib/_stream_writable.js:394:5)
    at ResponseStream.Writable.write (/Users/alan/.iim/dists/js-ipfs@0.36.0-rc.0/node_modules/readable-stream/lib/_stream_writable.js:303:11)
    at BufferPeekStream.ondata (_stream_readable.js:705:22)
    at BufferPeekStream.emit (events.js:193:13)
    at BufferPeekStream.Readable.read (_stream_readable.js:496:10)
    at flow (_stream_readable.js:969:34)
    at emitReadable_ (_stream_readable.js:564:3)
    at onEofChunk (_stream_readable.js:525:7)
    at readableAddChunk (_stream_readable.js:244:5)
/Users/alan/.iim/dists/js-ipfs@0.36.0-rc.0/node_modules/ipfs/src/cli/bin.js:8
  throw err
  ^
@jacobheun
Copy link
Contributor

Was the daemon running idle or were you running commands on it? Just curious.

Based on the stack trace it looks like a remote peer ended the connection as we were writing to it and there is an edge case somewhere that's not ending the readable-stream. Since the stack trace isn't coming from pull-stream, I'm assuming we're losing the close/error propagation somewhere.

lidel added a commit to ipfs/js-ipfs that referenced this issue Jul 8, 2019
This removes buffer-peek-stream which caused uncaught errors
inside of Hapijs and replaces it with much simpler approach
to set content-type header in Gateway responses.

Closes libp2p/js-libp2p#374
Closes libp2p/pull-mplex#13

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
lidel added a commit to ipfs/js-ipfs that referenced this issue Jul 12, 2019
This is an alternative to #2227
that does not hit datastore twice.

The underlying error was caused by multiple PassThrough/pipe calls.
Turns out go-ipfs does not compress anything by default, so we can
remove PassThrough responsible for streaming of compressed payload
and fix the issue while keeping optimization introduced by buffer-peek-stream.

Closes libp2p/js-libp2p#374
Closes libp2p/pull-mplex#13

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
alanshaw pushed a commit to ipfs/js-ipfs that referenced this issue Jul 12, 2019
This is an alternative to #2227
that does not hit datastore twice.

The underlying error was caused by multiple PassThrough/pipe calls.
Turns out go-ipfs does not compress anything by default, so we can
remove PassThrough responsible for streaming of compressed payload
and fix the issue while keeping optimization introduced by buffer-peek-stream.

Closes libp2p/js-libp2p#374
Closes libp2p/pull-mplex#13

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants