Repository navigation
Conversation
A write held by HTTP/2 flow control, the retry buffer, name resolution, or load balancing never ran its callback if the call was cancelled, exceeded its deadline, or the server finished it. Invoke each pending callback once with that error, and leave buffered bidi responses readable. Publish the terminal write error before either callback so a queued write sees it. Pass write() through to Node after end() or destroy(). Keep later retry-buffer callbacks until earlier ones settle, queue every message held for name resolution, and do not run an interceptor write callback twice after cancel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3114
Problem
When a client-streaming or bidirectional-streaming write is held in
@grpc/grpc-js(by HTTP/2 flow control, the retry buffer, name resolution, load-balancing subchannel pick, an active client interceptor, or aSingleSubchannelChannelawaiting call setup) and the call ends viacancel(), deadline expiration, or the server finishing the RPC, the write callback passed tostream.write(chunk, cb)remained pending indefinitely instead of settling with an error.Solution
Http2SubchannelCall,SingleSubchannelChannel,LoadBalancingCall,RetryingCall,ResolvingCall,InterceptingCall, and the publicClientWritableStreamImpl/ClientDuplexStreamImplsurface streams when the call terminates before those writes are accepted by the transport.terminalWriteErroron the surface stream before invoking callbacks so buffered and re-entrant writes share the same failure, while passingundefinedto Node's internal_writecallback so'finish'/end(cb)and readable buffered bidirectional responses remain intact.write()afterend()/destroy()directly toWritable/Duplexand roll back callback-queue entries ifsuper.writethrows synchronously (such aswrite(null, cb)).ResolvingCall,InterceptingCall(whilestartmetadata is pending), andSingleSubchannelChannel, and avoid double-invoking interceptor write callbacks whennext()is repeated aftercancel().Verification
npx tsc -p .inpackages/grpc-jsGRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION=true npx mocha --timeout 20000 --exit build/test/test-streaming-write-callback.js build/test/test-retry.js build/test/test-client.js(71 passing)