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
does not support the new Node.js 10.9 signature http.request(url[, options][, callback])
#1227
Comments
I’m not familiar enough with the code base myself to tell what the problem could be. The runkit notebook is much appreciated, thank you! Would you like to get a PR going? A failing test would be good enough, you can adjust the |
I had a brief look at the source code and tests, but I couldn't figure out where the appropriate place would be (neither for the fix nor for the test) 😕 AFAICT, tests are already being run on Node.js 10 on Travis, so that is taken care of. And as for a failing testcase, it is as simple as |
You are correct ✅ I used the following hack in common.js:138 to quickly get it running with the new signature:
Of course this is not a production-ready solution. |
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 fear nobody is super familiar with the code base right now, but we are working on cleaning that up. We just dropped support for Node < 10, come join the fun :) |
Fixes nock#1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source.
Fixes nock#1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source.
Fixes nock#1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source.
Fixes nock#1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source.
* Allow three arg form of `request` and `ClientRequest`. Fixes #1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source. * Remove unnecessary overrider in intercept. * Register ClientRequest callback on response event. Instead of passing it all around the overrider. This mimics how the native implementation does it.
🎉 This issue has been resolved in version 11.0.0-beta.22 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* [TT-347] - Add logic to proxy request when endpoint is not in draft state - Address PR comments - Write headers to proxied response - Add test coverage for mockserver - Updgrade nock to address nock/nock#1227 - Add test to ensure mock data is returned when expected
🎉 This issue has been resolved in version 11.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* Allow three arg form of `request` and `ClientRequest`. Fixes #1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source. * Remove unnecessary overrider in intercept. * Register ClientRequest callback on response event. Instead of passing it all around the overrider. This mimics how the native implementation does it.
* Allow three arg form of `request` and `ClientRequest`. Fixes #1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source. * Remove unnecessary overrider in intercept. * Register ClientRequest callback on response event. Instead of passing it all around the overrider. This mimics how the native implementation does it.
* Allow three arg form of `request` and `ClientRequest`. Fixes #1227 Beginning with v10.9.0, the `url` parameter can be passed along with a separate options object to `http[s].request`, `http[s].get`, or to the constructor of `ClientRequest`. https://nodejs.org/api/http.html#http_http_request_url_options_callback The logic that does the juggling was mostly copied from Node's source. * Remove unnecessary overrider in intercept. * Register ClientRequest callback on response event. Instead of passing it all around the overrider. This mimics how the native implementation does it.
What is the expected behavior?
Using the new signature for
http.request(url, options[, callback])
/http.get(url, options[, callback])
(introduced in Node.js v10.9, should work withnock
.What is the actual behavior?
With
nock
(by merelyrequire
ingnock
), it throws:Possible solution
I haven't looked at the code, but I suspect
nock
assumes the second argument is always the callback and uses it as such, whereas in Node.js 10.9+, the second argument can be an object (with the third being the callback). It should be trivial to detect that situation and pass the correct arguments tohttp.request()
(or something like that 😁).How to reproduce the issue
Runkit: Example link
Does the bug have a test case?
(Not sure wht this means.)
Versions
The text was updated successfully, but these errors were encountered: