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

stream: improve multiple callback error message #12520

Merged
merged 1 commit into from May 22, 2017

Conversation

Projects
None yet
9 participants
@cjihrig
Contributor

cjihrig commented Apr 19, 2017

When a transform stream's callback is called more than once, an error is emitted with a somewhat confusing message. This commit hopes to improve the quality of the error message.

Fixes: #12513

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

stream

Show outdated Hide outdated lib/_stream_transform.js
function emitMultipleCallsError() {
this.emit('error', new Error('write callback called multiple times'));
}

This comment has been minimized.

@jasnell

jasnell Apr 19, 2017

Member

I'm good with this, but it may make sense at some point to make this a utility in internal/util given that there may be several places where we'd want to avoid calling a callback more than once

@jasnell

jasnell Apr 19, 2017

Member

I'm good with this, but it may make sense at some point to make this a utility in internal/util given that there may be several places where we'd want to avoid calling a callback more than once

Show outdated Hide outdated lib/_stream_transform.js
@@ -92,7 +96,7 @@ function afterTransform(stream, er, data) {
return stream.emit('error', new Error('no writecb in Transform class'));
ts.writechunk = null;
ts.writecb = null;
ts.writecb = emitMultipleCallsError.bind(stream);

This comment has been minimized.

@cjihrig

cjihrig Apr 19, 2017

Contributor

Note. If this PR gets accepted, this bind() could be moved to, for example, the stream constructor, and hidden with a symbol. That would avoid rebinding every time.

@cjihrig

cjihrig Apr 19, 2017

Contributor

Note. If this PR gets accepted, this bind() could be moved to, for example, the stream constructor, and hidden with a symbol. That would avoid rebinding every time.

Show outdated Hide outdated lib/_stream_transform.js
@@ -92,7 +96,7 @@ function afterTransform(stream, er, data) {
return stream.emit('error', new Error('no writecb in Transform class'));

This comment has been minimized.

@kt3k

kt3k Apr 20, 2017

Contributor

Isn't this line useless if you assign non-null value to ts.writecb below?

@kt3k

kt3k Apr 20, 2017

Contributor

Isn't this line useless if you assign non-null value to ts.writecb below?

This comment has been minimized.

@cjihrig

cjihrig Apr 20, 2017

Contributor

I left this alone to be safe. However, I haven't found any path to this code that doesn't involve calling the callback twice, or using internal APIs. If that's the case, the fix can be as simple as changing the error message on this line. I'll take a look in the morning.

@cjihrig

cjihrig Apr 20, 2017

Contributor

I left this alone to be safe. However, I haven't found any path to this code that doesn't involve calling the callback twice, or using internal APIs. If that's the case, the fix can be as simple as changing the error message on this line. I'll take a look in the morning.

@mcollina

This comment has been minimized.

Show comment
Hide comment
@mcollina

mcollina May 19, 2017

Member

@mscdex why semver-major?

Member

mcollina commented May 19, 2017

@mscdex why semver-major?

@mscdex

This comment has been minimized.

Show comment
Hide comment
@mscdex

mscdex May 19, 2017

Contributor

@mcollina Change in error message?

Contributor

mscdex commented May 19, 2017

@mcollina Change in error message?

@mcollina

This comment has been minimized.

Show comment
Hide comment
@mcollina

mcollina May 19, 2017

Member

@mscdex great, I think we can release it with a minor in readable-stream cc @calvinmetcalf.

I'm fine with a minor here as well, I do not think anyone is relying on this error, the whole stream is broken if the error happens anyway.

Member

mcollina commented May 19, 2017

@mscdex great, I think we can release it with a minor in readable-stream cc @calvinmetcalf.

I'm fine with a minor here as well, I do not think anyone is relying on this error, the whole stream is broken if the error happens anyway.

@mscdex

This comment has been minimized.

Show comment
Hide comment
@mscdex

mscdex May 19, 2017

Contributor

@mcollina I think we still have the policy that any error message changes are automatically semver-major, so I don't see that changing here. Perhaps later on down the road after the new centralized error information has been around for awhile we can revisit that policy.

Contributor

mscdex commented May 19, 2017

@mcollina I think we still have the policy that any error message changes are automatically semver-major, so I don't see that changing here. Perhaps later on down the road after the new centralized error information has been around for awhile we can revisit that policy.

@calvinmetcalf

This comment has been minimized.

Show comment
Hide comment
@calvinmetcalf

calvinmetcalf May 19, 2017

Member

yeah especially considering it wasn't a documented error message, we can get away with minor in readable-streams

Member

calvinmetcalf commented May 19, 2017

yeah especially considering it wasn't a documented error message, we can get away with minor in readable-streams

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig May 19, 2017

Contributor

Updated to only change the error message. CI: https://ci.nodejs.org/job/node-test-pull-request/8175/

Contributor

cjihrig commented May 19, 2017

Updated to only change the error message. CI: https://ci.nodejs.org/job/node-test-pull-request/8175/

Show outdated Hide outdated lib/_stream_transform.js
@@ -89,7 +89,8 @@ function afterTransform(stream, er, data) {
var cb = ts.writecb;
if (!cb)

This comment has been minimized.

@mscdex

mscdex May 19, 2017

Contributor

Can we add braces here since the body is now multi-line?

@mscdex

mscdex May 19, 2017

Contributor

Can we add braces here since the body is now multi-line?

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig May 19, 2017

Contributor

Added curly braces, and CI was green.

Contributor

cjihrig commented May 19, 2017

Added curly braces, and CI was green.

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig May 19, 2017

Contributor

@jasnell @abouthiroppy you may want to re-review

Contributor

cjihrig commented May 19, 2017

@jasnell @abouthiroppy you may want to re-review

@mcollina

LGTM

@jasnell

LGTM. We still need to get the errors in here converted over to use internal/errors tho... so that's something to keep in mind for later

stream: improve multiple callback error message
When a transform stream's callback is called more than once,
an error is emitted with a somewhat confusing message. This
commit hopes to improve the quality of the error message.

Fixes: #12513
PR-URL: #12520
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@cjihrig cjihrig merged commit f8c617d into nodejs:master May 22, 2017

@cjihrig cjihrig deleted the cjihrig:err-msg branch May 22, 2017

@MylesBorins

This comment has been minimized.

Show comment
Hide comment
@MylesBorins

MylesBorins May 22, 2017

Member

this technically landed after the semver major cutoff @nodejs/ctc does anyone have an issue with this landing in the 8.0.0 release?

Member

MylesBorins commented May 22, 2017

this technically landed after the semver major cutoff @nodejs/ctc does anyone have an issue with this landing in the 8.0.0 release?

jasnell added a commit that referenced this pull request May 23, 2017

stream: improve multiple callback error message
When a transform stream's callback is called more than once,
an error is emitted with a somewhat confusing message. This
commit hopes to improve the quality of the error message.

Fixes: #12513
PR-URL: #12520
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell added a commit that referenced this pull request May 23, 2017

stream: improve multiple callback error message
When a transform stream's callback is called more than once,
an error is emitted with a somewhat confusing message. This
commit hopes to improve the quality of the error message.

Fixes: #12513
PR-URL: #12520
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@jasnell jasnell referenced this pull request May 28, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment