Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Fix error handling bug in stream.pipe() #1095

Closed
wants to merge 1 commit into from

Commits on May 23, 2011

  1. Fix error handling bug in stream.pipe()

    Problem: Since stream.pipe() is registering it's own error handlers on
    the source and destination stream, it needs to replicate the
    EventEmitter 'error' emitting semantics of throwing an error if there
    are no other listeners. However, there was a off-by-one error because
    the check for remaining listeners was done after cleanup() which means
    the pipe's own listener was no longer included.
    
    This would cause 'error' events on either the dest or the source to
    throw if there was one other error listener, and while swallowing
    the 'error' event if there was no other listener.
    
    Solution: I added a test demonstrating the two issues and fixed the
    problem by correcting the off-by-one error.
    felixge committed May 23, 2011
    Configuration menu
    Copy the full SHA
    9b499e0 View commit details
    Browse the repository at this point in the history