Copilot commented on code in PR #3875:
URL: https://github.com/apache/avro/pull/3875#discussion_r3570110366


##########
lang/js/lib/files.js:
##########
@@ -213,6 +233,9 @@ BlockDecoder.prototype._write = function (chunk, encoding, 
cb) {
   tap.pos = 0;
 
   if (!this._decodeHeader()) {
+    if (this._errored) {
+      return; // Destroyed while decoding the header; leave the write callback.
+    }
     process.nextTick(cb);
     return;
   }

Review Comment:
   In the fatal-header-error path, `_decodeHeader()` calls `_onError()` which 
`destroy()`s the stream, but `_write` then returns without ever invoking the 
`cb` write callback. Even though the stream is being destroyed, leaving the 
write callback pending can stall upstream writers/pipelines and leaves the 
writable state mid-write. Call `cb()` (or `process.nextTick(cb)`) before 
returning when `_errored` is set.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to