grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

@grpc/grpc-js Abort on ClientReadableStream cancel

Open ozt88 opened this issue 5 years ago • 9 comments

Problem description

invoking ClientReadableStream.cancel() cause abort

node[8728]: ../src/node_http2.cc:448:void node::http2::Http2Session::CheckAllocatedSize(size_t) const: Assertion `(current_nghttp2_memory_) >= (previous_size)' failed.
 1: 0xa03530 node::Abort() [node]
 2: 0xa035ae  [node]
 3: 0xa3ba6b node::mem::NgLibMemoryManager<node::http2::Http2Session, nghttp2_mem>::ReallocImpl(void*, unsigned long, void*) [node]
 4: 0xa3bc43 node::mem::NgLibMemoryManager<node::http2::Http2Session, nghttp2_mem>::FreeImpl(void*, void*) [node]
 5: 0x1865d81 nghttp2_session_close_stream [node]
 6: 0x186c4e4 nghttp2_session_mem_recv [node]
 7: 0xa2faa9 node::http2::Http2Session::ConsumeHTTP2Data() [node]
 8: 0xa2fe18 node::http2::Http2Session::OnStreamRead(long, uv_buf_t const&) [node]
 9: 0xada258 node::LibuvStreamWrap::OnUvRead(long, uv_buf_t const*) [node]
10: 0x1385197  [node]
11: 0x1385b50  [node]
12: 0x138c545  [node]
13: 0x137a398 uv_run [node]
14: 0xa438d4 node::NodeMainInstance::Run() [node]
15: 0x9d1735 node::Start(int, char**) [node]
16: 0x7fd5025050b3 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
17: 0x96971c  [node]
Aborted

but when I use 'grpc' module with same code, there is no abort.

Reproduction steps

invoke ClientReadableStream.cancel()

Environment

  • OS name, version and architecture: [WSL Ubuntu 20.04.1 amd64]
  • Node version [14.15.1]
  • Node installation method [nvm]
  • If applicable, compiler version []
  • Package name and version [@grpc/[email protected]]

Additional context

ozt88 avatar Dec 10 '20 03:12 ozt88

I believe this may be related to #1464.

sangaman avatar Dec 18 '20 18:12 sangaman

Wrapping the .cancel() call with setTimeout/setImmediate seems to mitigate the error.

LePremierHomme avatar Dec 21 '20 22:12 LePremierHomme

Wrapping the .cancel() call with setTimeout/setImmediate seems to mitigate the error.

this works for me

ozt88 avatar Dec 22 '20 01:12 ozt88

I've opened an issue against nodejs as I ran into a similar issue https://github.com/nodejs/node/issues/38964

mdouglass avatar Jun 08 '21 06:06 mdouglass

I'm investigating it there.

bl-ue avatar Jun 08 '21 12:06 bl-ue

ping @jasnell: see the stacktrace? Does that tell you anything right away?

bl-ue avatar Jun 08 '21 12:06 bl-ue

This is a Node bug and it appears to have been fixed in Node.

murgatroid99 avatar Jan 18 '22 22:01 murgatroid99

This issue has not been completely fixed in node https://github.com/nodejs/node/issues/38964 is still open

Matt-Esch avatar Aug 15 '22 04:08 Matt-Esch

Yes, I see that that issue was reopened since I made that comment. It is still a Node bug, not a grpc-js bug.

murgatroid99 avatar Aug 15 '22 16:08 murgatroid99