npm / minipass-fetch

An implementation of window.fetch in Node.js using Minipass streams
Other
54 stars 11 forks source link

fix: correctly handle error events that happen after response events #14

Closed nlf closed 3 years ago

nlf commented 3 years ago

i wrote a pretty long comment in the code to be sure that the error propagation never gets accidentally removed, and we remember to account for this situation when we eventually refactor this.

this resolves a lot of the cb() never called errors, especially those in Windows where i was able to reproduce the bug pretty easily. i suspect there's a similar issue in other operating systems, but was unable to prove it. similarly testing this proved somewhat difficult since the underlying request object is inaccessible from the response object the promise resolves to, so there isn't an easy way to manually trigger this problem.

this code is definitely due some refactoring, and as part of that it would be nice to allow access to the raw request and response objects so that we can test this accurately, but that work should not delay getting this fix released.