| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/13194/ |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
There was a problem hiding this comment.
I think the correct behavior for these is to emit('error'). Note that calling the callback with an error will have that result.
Sorry, something went wrong.
There was a problem hiding this comment.
I would leave this as this.emit('error').
Sorry, something went wrong.
There was a problem hiding this comment.
Can you elaborate on the reasons?
Sorry, something went wrong.
There was a problem hiding this comment.
I would change this as cb(new errors.Error()).
Sorry, something went wrong.
There was a problem hiding this comment.
I would leave this as it was.
Sorry, something went wrong.
There was a problem hiding this comment.
👍!
Sorry, something went wrong.
Yes, I changed it because I think it doesn't make sense to emit the error, it should just crash as the method has not been implemented. If there is an 'error' listener this may go unnoticed. Anyway happy to always emit the error instead of throwing if there is consensus. |
Sorry, something went wrong.
|
I think throwing is not the way to go, mainly because that error is likely not to be catchable in any way. |
Sorry, something went wrong.
|
I agree with @mcollina that these should be emit('error', ...) ... it's much more consistent with what users expect with stream implementations. |
Sorry, something went wrong.
Isn't this the point of the error? We throw for invalid arguments or options, in my opinion this is the same kind of error (invalid implementation). I guess this Line 608 in 6c9774f |
Sorry, something went wrong.
|
The reason why these needs to be emitted is because they could be called asynchronously. In such cases it would be hard to track to which stream they belong. |
Sorry, something went wrong.
|
I still fail to understand.
That said, I will change this PR to always emit if this is the right thing to do. Pinging @nodejs/collaborators. |
Sorry, something went wrong.
|
No one commented and there are 2 TSC members that prefer to emit, so I've updated accordingly. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
This needs a rebase |
Sorry, something went wrong.
Sorry, something went wrong.
|
@mcollina @jasnell e.g. all our fs errors throw sync instead of returning the error in the callback. That is also true for any other part of the code. So I am still not convinced about using emit here. All of that code could be used async. The only way I can imagine how these functions could be called is by faulty user code. And for me that is the same as the fs case. |
Sorry, something went wrong.
|
@BridgeAR I would agree if those function were called sync all the time. In non-trivial cases, those methods are called async. |
Sorry, something went wrong.
|
@mcollina it doesn't matter imho, what's the difference, any method or function that throws synchronously can be called async. |
Sorry, something went wrong.
|
All Node APIs can be called async from user code. These are called async from Node.js code. |
Sorry, something went wrong.
|
I think when to throw such errors depends on the nature of those errors: can they be expected from a user, or are they just bugs/incorrect usage of APIs. In the first case it make sense to throw asynchronously because we cannot know the result of an async operation synchronously anyway. In the second case it makes sense to throw synchronously because those errors are more like assertions in nature. The async operations cannot even be initiated so there is not really much point to delay the notification. Also the user cannot really handle those errors (type checking, streams not implemented, etc) in their code anyway. The only sane way to handle those errors is probably just throw it again. If they try to handle a ERR_INVALID_* or ERR_METHOD_NOT_IMPLEMENTED they are probably just going to leave their program in a really bad state. |
Sorry, something went wrong.
Use the same error code and always emit the error instead of throwing it.
|
I will land this tomorrow, got bored of rebasing :) |
Sorry, something went wrong.
Use the same error code and always emit the error instead of throwing it. PR-URL: #18813 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaë Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Use the same error code and always emit the error instead of throwing it. PR-URL: nodejs#18813 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaë Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This removes two unused error codes: * ERR_STREAM_READ_NOT_IMPLEMENTED, removed in c979488 (PR nodejs#18813). * ERR_VALUE_OUT_OF_RANGE, removed in d022cb1 (PR nodejs#17648). PR-URL: nodejs#21491 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This removes two unused error codes: * ERR_STREAM_READ_NOT_IMPLEMENTED, removed in c979488 (PR #18813). * ERR_VALUE_OUT_OF_RANGE, removed in d022cb1 (PR #17648). PR-URL: #21491 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
| Back | FazBrowse Home | New Git URL |
Use the same error code and always emit the error instead of throwing it.
Checklist
Affected core subsystem(s)
errors, stream