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
TypeError in Node 12 #1509
Comments
Thanks for the report! We'd be happy to have help looking into and addressing the root cause! |
It looks like it has to do with the allowed arguments to Not sure why this is different in Node 12, though. 🤔 It would be helpful to have some more tests written from the perspective of an http client library, which check that the functions can be called in all the same ways as the native functions. |
The "problem" is that V11
V12
request_overrider's req.write should handle the "optionality" of arguments and not blindly pass them to |
I am now applying this patch to nock 10.0.6 to have my CI pass under node 12. It's probably not the complete solution tho. |
@panva meta question: how do the patches get applied in https://github.com/panva/node-oidc-provider? |
@gr2m travis.yml before_script hook using patch-package module. |
For reference, here is how Node handles the optional params for Personally, I prefer @panva version because Node allows for |
This issue feels important to resolve! ♨️
We should definitely match Node's behavior and the docs. If Node's behavior and the docs conflict we can match the behavior, though we obviously should not implement any new behavior. This should be tested with a test that uses In general I'd like to segregate the tests that test nock's mock surface, i.e. the part that HTTP clients interact with, from the high-level functional tests calling through the nock public interface, that make up most of our tests. The new tests for this issue could go in a new file and I can work on collecting the rest of these tests at a later date. If anyone wants to pick this up, I'd be happy to review it! |
According to docs, `req.end` can accept callback as a first argument. That's what `got` module does. Fixes nock#1509 ``` request.end([data[, encoding]][, callback])# History data <string> | <Buffer> encoding <string> callback <Function> Returns: <this> Finishes sending the request. If any parts of the body are unsent, it will flush them to the stream. If the request is chunked, this will send the terminating '0\r\n\r\n'. If data is specified, it is equivalent to calling request.write(data, encoding) followed by request.end(callback). If callback is specified, it will be called when the request stream is finished. ```
According to docs, `req.end` can accept callback as a first argument. That's what `got` module does. Fixes nock#1509 ``` request.end([data[, encoding]][, callback])# History data <string> | <Buffer> encoding <string> callback <Function> Returns: <this> Finishes sending the request. If any parts of the body are unsent, it will flush them to the stream. If the request is chunked, this will send the terminating '0\r\n\r\n'. If data is specified, it is equivalent to calling request.write(data, encoding) followed by request.end(callback). If callback is specified, it will be called when the request stream is finished. ```
According to the docs, `req.end` can accept callback as a first argument. That's what `got` module does. Closes #1509 ``` request.end([data[, encoding]][, callback])# History data <string> | <Buffer> encoding <string> callback <Function> Returns: <this> Finishes sending the request. If any parts of the body are unsent, it will flush them to the stream. If the request is chunked, this will send the terminating '0\r\n\r\n'. If data is specified, it is equivalent to calling request.write(data, encoding) followed by request.end(callback). If callback is specified, it will be called when the request stream is finished. ```
🎉 This issue has been resolved in version 11.0.0-beta.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@paulmelnikow would it be too much of a hassle to land this on the 10.x release line as well? |
11.x will be released very soon and feedback on the beta releases would be very helpful. Though if someone wants to backport the fix and the test in a new PR on the master branch, I suppose we could ship it! |
Thanks, I upgraded to 11.0.0-beta.13, works fine for me |
Do we? According to the docs, signature is According to this, https://nodejs.org/api/http.html#http_request_end_data_encoding_callback |
@gugu check out my comment above, #1509 (comment) Since we're trying to mimic, it might be worth simply copying the implementation from the Node source, despite the docs. 🤷♂ |
Ah, indeed! Though I think we're not handling Added: I think matching the undocumented behavior of the implementation is a good idea. |
@gugu thanks for taking the time to fix this! |
* nock@10.0.6 -> nock@11.0.0-beta.13 Addressed this bug: nock/nock#1509
🎉 This issue has been resolved in version 11.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
According to the docs, `req.end` can accept callback as a first argument. That's what `got` module does. Closes #1509 ``` request.end([data[, encoding]][, callback])# History data <string> | <Buffer> encoding <string> callback <Function> Returns: <this> Finishes sending the request. If any parts of the body are unsent, it will flush them to the stream. If the request is chunked, this will send the terminating '0\r\n\r\n'. If data is specified, it is equivalent to calling request.write(data, encoding) followed by request.end(callback). If callback is specified, it will be called when the request stream is finished. ```
According to the docs, `req.end` can accept callback as a first argument. That's what `got` module does. Closes #1509 ``` request.end([data[, encoding]][, callback])# History data <string> | <Buffer> encoding <string> callback <Function> Returns: <this> Finishes sending the request. If any parts of the body are unsent, it will flush them to the stream. If the request is chunked, this will send the terminating '0\r\n\r\n'. If data is specified, it is equivalent to calling request.write(data, encoding) followed by request.end(callback). If callback is specified, it will be called when the request stream is finished. ```
According to the docs, `req.end` can accept callback as a first argument. That's what `got` module does. Closes #1509 ``` request.end([data[, encoding]][, callback])# History data <string> | <Buffer> encoding <string> callback <Function> Returns: <this> Finishes sending the request. If any parts of the body are unsent, it will flush them to the stream. If the request is chunked, this will send the terminating '0\r\n\r\n'. If data is specified, it is equivalent to calling request.write(data, encoding) followed by request.end(callback). If callback is specified, it will be called when the request stream is finished. ```
A quick heads up, feel free to close once you acknowledge. The test suite does not pass under node 12 (both nock latest and beta channels).
Tested using node nighly build, installed using
Here's the trace i'm getting when pre-testing my modules' test suite relying on nock under node 12, same issue.
The text was updated successfully, but these errors were encountered: