New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nock is not compatible with stream.pipeline(...)
#1832
Comments
This seems to happen because the "no match" error that is emitted, when a scope matches but not an interceptor, emits after a nock/lib/intercepted_request_router.js Lines 290 to 297 in 3fbc69d
whereas the nock/lib/intercepted_request_router.js Lines 147 to 149 in 3fbc69d
Nock tries to replicate what Node does natively, but it's a little hard in this case since none of these events are documented. (I don't even think ClientRequest ever emits an I think the router should be updated to not emit Someone should probably dive into live examples of this flow a bit more first. I can be that someone, but my timeline would be a bit open. |
Given this example: const request = http.request('http://example.com');
request.once('finish', () => {
console.log('finish');
});
request.once('end', () => {
console.log('end');
});
request.abort();
request.end(); You will see that
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions. |
I forgot about this over the holidays, but good ol' Stale Bot did its job. First off it seems, something in Got was changed between 10.0.2 and 10.0.3, because running the "Code to reproduce" from the original Got ticket now rejects the promise (I think this commit). It should not emit an
@szmarczak agreed! But I was referring to the But I'm having a hard time justifying that it's not ok for a ClientRequest to have a Lastly, when I was playing around with different versions of these code reproductions, both with and without Nock for comparisons, I noticed that Nock is emitting errors when I have some changes locally that I'll clean up and PR, but I want to sleep on it first. |
Delays the emitting of the "finish" event on the request until it knows for sure an Interceptor is going to playback. This stops a double emit for unmocked requests. Also removes the "end" event from firing on the request. This event was added in the first commit with code for Nock and was used to kicked off the internals that now live in `startPlayback`. nock@31a500c#diff-503754c07b5098227646f913eee85885R27-R76 closes nock#1832
* fix(router): stall finish event to avoid dup Delays the emitting of the "finish" event on the request until it knows for sure an Interceptor is going to playback. This stops a double emit for unmocked requests. Also removes the "end" event from firing on the request. This event was added in the first commit with code for Nock and was used to kicked off the internals that now live in `startPlayback`. 31a500c#diff-503754c07b5098227646f913eee85885R27-R76 closes #1832
🎉 This issue has been resolved in version 12.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Please look at sindresorhus/got#976 for further information.
The text was updated successfully, but these errors were encountered: