Uh oh!
There was an error while loading. Please reload this page.
lib, test: migrate _http_outgoing.js's remaining errors to internal/errors.js - #17837
lib, test: migrate _http_outgoing.js's remaining errors to internal/errors.js#17837b0yfriend wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Since common.expectsError returns a function wrapped in common.mustCall that can be used as callbacks, can you simplify this to:
res.on('error',common.expectsError({code: 'ERR_STREAM_WRITE_AFTER_END',type: Error}));?
There was a problem hiding this comment.
common.expectsError can take a function and wraps it in assert.throws, can you simplify this to
common.expectsError(()=>{outgoingMessage.pipe(outgoingMessage);},{code: 'ERR_STREAM_CANNOT_PIPE',type: Error});?
There was a problem hiding this comment.
Can you simplify this to
res.on('error',common.expectsError({code: 'ERR_STREAM_WRITE_AFTER_END',type: Error}));?
A couple of lib/_http_outgoing.js's errors were still in the "old style": `throw new Error(<some message here>)`. This commit migrates those 2 old style errors to the "new style": internal/errors.js's error-system. In the future, changes to these errors' messages won't break semver-major status. With the old style, changes to these errors' messages broke semver-major status. It was inconvenient. Refs: #17709
Two of _http_outgoing.js's errors were migrated to the internal/errors.js system. This commit adapts _http_outgoing.js's tests accordingly. Refs: #17709
_http_outgoing.js's tests perform error-checks. They ensure that appropriate errors are thrown in the appropriate circumstances. A few error-checks were bloated. They used unnecessary intermediate functions. E.g. there were unnecessary combinations of `common.mustCall()` & `common.expectsError()` and `common.expectsError()` & `assert.throws()`. This commit removes those unnecessary intermediate functions. This simplifies the given error-checks.
| function handle(req, res) { | ||
| res.on('error', common.mustCall((err) => { | ||
| assert.strictEqual(err.message, 'write after end'); |
There was a problem hiding this comment.
Oh, I missed this. I'll fix it soon!
There was a problem hiding this comment.
^^ Addressed this remark in the comment below.
| code: 'ERR_STREAM_WRITE_AFTER_END', | ||
| type: Error | ||
| })(err); | ||
| server.close(); |
There was a problem hiding this comment.
Never mind. I thought I could remove the common.mustCall() on line 11, and simplify it to just common.expectsError().
That's what I did in test-pipe-outgoing-message-data-emitted-after-ended.js on lines 19-21.
However, I can't. This block performs server.close() in addition to common.expectsError(). That additional functionality prevents me from simplifying common.mustCall() => common.expectsError().
There was a problem hiding this comment.
The way to handle that would be to register two on('error') handlers, one with the expectsError() check and the second with the server.close() call.
b0yfriend
commented
Dec 24, 2017
@joyeecheung Are there any other concerns? |
joyeecheung
commented
Dec 24, 2017
These needs two TSC approvals. cc @nodejs/tsc |
b0yfriend
commented
Dec 24, 2017
lpinca
commented
Dec 25, 2017
@acparas failures seems to to be unrelated to this change. |
joyeecheung
commented
Dec 27, 2017
Landed in d3ac18a, thanks! |
A couple of lib/_http_outgoing.js's errors were still in the "old style": `throw new Error(<some message here>)`. This commit migrates those 2 old style errors to the "new style": internal/errors.js's error-system. In the future, changes to these errors' messages won't break semver-major status. With the old style, changes to these errors' messages broke semver-major status. It was inconvenient. Refs: #17709 PR-URL: #17837 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>

cc @jasnell@joyeecheung
A couple of
lib/_http_outgoing.js's errors were still in the "old style":throw new Error(<some message here>).This PR migrates those 2 old style errors to the "new style":
internal/errors.js's error-system.In the future, changes to these errors' messages won't break semver-major status. With the old style, changes to these errors' messages broke semver-major status. It was inconvenient.
This PR also adapts
_http_outgoing.js's tests accordingly.Refs: #17709
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
lib, test