Skip to content

timers: Migrate to use internal/errors - #14659

Closed
starkwang wants to merge 1 commit into
nodejs:masterfrom
starkwang:timers-internal-errors
Closed

timers: Migrate to use internal/errors#14659
starkwang wants to merge 1 commit into
nodejs:masterfrom
starkwang:timers-internal-errors

Conversation

@starkwang

@starkwangstarkwang commented Aug 7, 2017

Copy link
Copy Markdown
Contributor

ref: #11273

Migrate the timers module to use internal/errors. And some tests are added for timers.enroll().

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)

timers, test, errors

@nodejs-github-botnodejs-github-bot added the timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. label Aug 7, 2017
tniessen
tniessen previously approved these changes Aug 7, 2017
Comment threadlib/timers.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not contain information about the allowed range anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The motivation is to try to have minimal changes in the new error message
Suggestion (if it works):

errors.TypeError('ERR_INVALID_ARG_TYPE','msecs','a non-negative finite number',msecs);

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message will become like:

RangeError [ERR_INVALID_ARG_TYPE]: The "msecs" argument must be of type a non-negative finite number

IMHO, we should add a new error code (e.g. ERR_OPT_VALUE_OUT_OF_RANGE), which can be reused in other modules. (e.g. https://github.com/nodejs/node/blob/master/lib/buffer.js#L244)

@refackrefackAug 7, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍 (New error code)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: Trailing comma.

@tniessen
tniessen dismissed their stale reviewAugust 7, 2017 09:48

Didn't mean to approve, sorry.

@refackrefack added errors Issues and PRs related to JavaScript errors originated in Node.js core. semver-major PRs that contain breaking changes and should be released in the next major version. labels Aug 7, 2017
@refackrefack self-assigned this Aug 7, 2017
@starkwang
starkwangforce-pushed the timers-internal-errors branch 3 times, most recently from 46172ab to 65cd92aCompareAugust 7, 2017 15:33

@refackrefack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@refack

Copy link
Copy Markdown
Contributor

Comment threadlib/internal/errors.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: Received

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Comment threadlib/internal/errors.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint in L232:

not ok 3 - /usr/home/iojs/build/workspace/node-test-linter/lib/internal/errors.js
---
message: 'There should be no space before '',''.'
severity: error
data:
line: 232
column: 49
ruleId: comma-spacing
messages:
- message: 'A space is required after '',''.'
severity: error
data:
line: 232
column: 49
ruleId: comma-spacing
...

@starkwang
starkwangforce-pushed the timers-internal-errors branch 2 times, most recently from 7727304 to cd2e3efCompareAugust 8, 2017 00:08
@starkwang

Copy link
Copy Markdown
ContributorAuthor

Fixed typo and lint

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small nit, LGTM otherwise

Comment threadlib/internal/errors.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistency it would be best to use %s and rely on util.format instead of using a function.

@starkwang
starkwangforce-pushed the timers-internal-errors branch from cd2e3ef to fc7e71dCompareAugust 8, 2017 06:14

@Fishrock123Fishrock123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tniessen pushed a commit that referenced this pull request Aug 16, 2017
req.socket._hadError should be set before emitting the error event.
PR-URL: #14659
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@tniessen

Copy link
Copy Markdown
Member

The above commit 620ba41 should not have referenced this PR, sorry for any confusion.
By the way, we still need someone from @nodejs/ctc to sign this off.

Comment threaddoc/api/errors.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: OPT_VALUE is not intuitive. ERR_VALUE_OUT_OF_RANGE would be better I guess.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include zero, for boundary checking and NaN, for special case?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero is valid for argument msecs. I've added NaN for special case.

@starkwang
starkwangforce-pushed the timers-internal-errors branch from fc7e71d to b042d19CompareAugust 18, 2017 02:04
MSLaguana pushed a commit to nodejs/node-chakracore that referenced this pull request Aug 21, 2017
req.socket._hadError should be set before emitting the error event.
PR-URL: nodejs/node#14659
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@starkwang
starkwangforce-pushed the timers-internal-errors branch from b042d19 to 7a09080CompareAugust 24, 2017 05:21

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM

@BridgeAR

Copy link
Copy Markdown
Member

Landed in 4d893e0

BridgeAR pushed a commit that referenced this pull request Aug 27, 2017
PR-URL: #14659
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
PR-URL: nodejs/node#14659
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
ghost pushed a commit to ayojs/ayo that referenced this pull request Aug 30, 2017
PR-URL: nodejs/node#14659
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
jasnell added a commit that referenced this pull request Oct 17, 2017
* **async_hooks**
* Older experimental `async_hooks` APIs have been removed
[[`d731369b1d`](d731369b1d)]
**(SEMVER-MAJOR)** [#14414](#14414)
* **Errors**
* Multiple built in modules have been migrated to use static error codes
* **Domains**
* The long deprecated `.dispose()` method has been removed
[[`602fd36d95`](602fd36d95)]
**(SEMVER-MAJOR)** [#15412](#15412)
* **File system**
* `fs.ReadStream` and `fs.WriteStream` now make use of `.destroy()`
[[`e5c290bed9`](e5c290bed9)]
**(SEMVER-MAJOR)** [#15407](#15407)
* `fs` callbacks are now invoked with an undefined `this` context
[[`2249234fee`](2249234fee)]
**(SEMVER-MAJOR)** [#14645](#14645)
* **HTTP**
* Socket timeout is set when the socket connects
[[`10be20a0e8`](10be20a0e8)]
**(SEMVER-MAJOR)** [#8895](#8895)
* A bug causing the request `error` event to fire twice has been fixed
[[`620ba41694`](620ba41694)]
**(SEMVER-MAJOR)** [#14659](#14659)
* The `pipe` method on `OutgoingMessage` has been disabled
[[`156549d8ff`](156549d8ff)]
**(SEMVER-MAJOR)** [#14358](#14358)
* **HTTP/2**
* The `--expose-http2` command-line argument is no longer required
[[`f55ee6e24a`](f55ee6e24a)]
**(SEMVER-MAJOR)** [#15535](#15535)
* **Internationalization**
* The `Intl.v8BreakIterator` class has been removed
[[`668ad44922`](668ad44922)]
**(SEMVER-MAJOR)** [#15238](#15238)
* **OS**
* `os.EOL` is now read-only
[[`f6caeb9526`](f6caeb9526)]
**(SEMVER-MAJOR)** [#14622](#14622)
* **Process**
* It is now possible to pass additional flags to `dlopen`
[[`5f22375922`](5f22375922)]
**(SEMVER-MAJOR)** [#12794](#12794)
* **Timers**
* Using a timeout duration larger than 32-bits will now emit a warning
[[`ce3586da31`](ce3586da31)]
**(SEMVER-MAJOR)** [#15627](#15627)
* **TLS**
* `parseCertString` has been deprecated
[[`468110b327`](468110b327)]
**(SEMVER-MAJOR)** [#14249](#14249)
* Type-checking for `key`, `cert`, and `ca` options has been added
[[`a7dccd040d`](a7dccd040d)]
**(SEMVER-MAJOR)** [#14807](#14807)
jasnell added a commit that referenced this pull request Oct 29, 2017
* **async_hooks**
* Older experimental `async_hooks` APIs have been removed
[[`d731369b1d`](d731369b1d)]
**(SEMVER-MAJOR)** [#14414](#14414)
* **Errors**
* Multiple built in modules have been migrated to use static error codes
* **Domains**
* The long deprecated `.dispose()` method has been removed
[[`602fd36d95`](602fd36d95)]
**(SEMVER-MAJOR)** [#15412](#15412)
* **File system**
* `fs.ReadStream` and `fs.WriteStream` now make use of `.destroy()`
[[`e5c290bed9`](e5c290bed9)]
**(SEMVER-MAJOR)** [#15407](#15407)
* `fs` callbacks are now invoked with an undefined `this` context
[[`2249234fee`](2249234fee)]
**(SEMVER-MAJOR)** [#14645](#14645)
* **HTTP**
* Socket timeout is set when the socket connects
[[`10be20a0e8`](10be20a0e8)]
**(SEMVER-MAJOR)** [#8895](#8895)
* A bug causing the request `error` event to fire twice has been fixed
[[`620ba41694`](620ba41694)]
**(SEMVER-MAJOR)** [#14659](#14659)
* The `pipe` method on `OutgoingMessage` has been disabled
[[`156549d8ff`](156549d8ff)]
**(SEMVER-MAJOR)** [#14358](#14358)
* **HTTP/2**
* The `--expose-http2` command-line argument is no longer required
[[`f55ee6e24a`](f55ee6e24a)]
**(SEMVER-MAJOR)** [#15535](#15535)
* **Internationalization**
* The `Intl.v8BreakIterator` class has been removed
[[`668ad44922`](668ad44922)]
**(SEMVER-MAJOR)** [#15238](#15238)
* **OS**
* `os.EOL` is now read-only
[[`f6caeb9526`](f6caeb9526)]
**(SEMVER-MAJOR)** [#14622](#14622)
* **Process**
* It is now possible to pass additional flags to `dlopen`
[[`5f22375922`](5f22375922)]
**(SEMVER-MAJOR)** [#12794](#12794)
* **Timers**
* Using a timeout duration larger than 32-bits will now emit a warning
[[`ce3586da31`](ce3586da31)]
**(SEMVER-MAJOR)** [#15627](#15627)
* **TLS**
* `parseCertString` has been deprecated
[[`468110b327`](468110b327)]
**(SEMVER-MAJOR)** [#14249](#14249)
* Type-checking for `key`, `cert`, and `ca` options has been added
[[`a7dccd040d`](a7dccd040d)]
**(SEMVER-MAJOR)** [#14807](#14807)
jasnell added a commit that referenced this pull request Oct 29, 2017
* **async_hooks**
* Older experimental `async_hooks` APIs have been removed
[[`d731369b1d`](d731369b1d)]
**(SEMVER-MAJOR)** [#14414](#14414)
* **Errors**
* Multiple built in modules have been migrated to use static error codes
* **Domains**
* The long deprecated `.dispose()` method has been removed
[[`602fd36d95`](602fd36d95)]
**(SEMVER-MAJOR)** [#15412](#15412)
* **File system**
* `fs.ReadStream` and `fs.WriteStream` now make use of `.destroy()`
[[`e5c290bed9`](e5c290bed9)]
**(SEMVER-MAJOR)** [#15407](#15407)
* `fs` callbacks are now invoked with an undefined `this` context
[[`2249234fee`](2249234fee)]
**(SEMVER-MAJOR)** [#14645](#14645)
* **HTTP**
* Socket timeout is set when the socket connects
[[`10be20a0e8`](10be20a0e8)]
**(SEMVER-MAJOR)** [#8895](#8895)
* A bug causing the request `error` event to fire twice has been fixed
[[`620ba41694`](620ba41694)]
**(SEMVER-MAJOR)** [#14659](#14659)
* The `pipe` method on `OutgoingMessage` has been disabled
[[`156549d8ff`](156549d8ff)]
**(SEMVER-MAJOR)** [#14358](#14358)
* **HTTP/2**
* The `--expose-http2` command-line argument is no longer required
[[`f55ee6e24a`](f55ee6e24a)]
**(SEMVER-MAJOR)** [#15535](#15535)
* **Internationalization**
* The `Intl.v8BreakIterator` class has been removed
[[`668ad44922`](668ad44922)]
**(SEMVER-MAJOR)** [#15238](#15238)
* **OS**
* `os.EOL` is now read-only
[[`f6caeb9526`](f6caeb9526)]
**(SEMVER-MAJOR)** [#14622](#14622)
* **Process**
* It is now possible to pass additional flags to `dlopen`
[[`5f22375922`](5f22375922)]
**(SEMVER-MAJOR)** [#12794](#12794)
* **Timers**
* Using a timeout duration larger than 32-bits will now emit a warning
[[`ce3586da31`](ce3586da31)]
**(SEMVER-MAJOR)** [#15627](#15627)
* **TLS**
* `parseCertString` has been deprecated
[[`468110b327`](468110b327)]
**(SEMVER-MAJOR)** [#14249](#14249)
* Type-checking for `key`, `cert`, and `ca` options has been added
[[`a7dccd040d`](a7dccd040d)]
**(SEMVER-MAJOR)** [#14807](#14807)
jasnell added a commit that referenced this pull request Oct 29, 2017
* **async_hooks**
* Older experimental `async_hooks` APIs have been removed
[[`d731369b1d`](d731369b1d)]
**(SEMVER-MAJOR)** [#14414](#14414)
* **Errors**
* Multiple built in modules have been migrated to use static error codes
* **Domains**
* The long deprecated `.dispose()` method has been removed
[[`602fd36d95`](602fd36d95)]
**(SEMVER-MAJOR)** [#15412](#15412)
* **File system**
* `fs.ReadStream` and `fs.WriteStream` now make use of `.destroy()`
[[`e5c290bed9`](e5c290bed9)]
**(SEMVER-MAJOR)** [#15407](#15407)
* `fs` callbacks are now invoked with an undefined `this` context
[[`2249234fee`](2249234fee)]
**(SEMVER-MAJOR)** [#14645](#14645)
* **HTTP**
* Socket timeout is set when the socket connects
[[`10be20a0e8`](10be20a0e8)]
**(SEMVER-MAJOR)** [#8895](#8895)
* A bug causing the request `error` event to fire twice has been fixed
[[`620ba41694`](620ba41694)]
**(SEMVER-MAJOR)** [#14659](#14659)
* The `pipe` method on `OutgoingMessage` has been disabled
[[`156549d8ff`](156549d8ff)]
**(SEMVER-MAJOR)** [#14358](#14358)
* **HTTP/2**
* The `--expose-http2` command-line argument is no longer required
[[`f55ee6e24a`](f55ee6e24a)]
**(SEMVER-MAJOR)** [#15535](#15535)
* **Internationalization**
* The `Intl.v8BreakIterator` class has been removed
[[`668ad44922`](668ad44922)]
**(SEMVER-MAJOR)** [#15238](#15238)
* **OS**
* `os.EOL` is now read-only
[[`f6caeb9526`](f6caeb9526)]
**(SEMVER-MAJOR)** [#14622](#14622)
* **Process**
* It is now possible to pass additional flags to `dlopen`
[[`5f22375922`](5f22375922)]
**(SEMVER-MAJOR)** [#12794](#12794)
* **Timers**
* Using a timeout duration larger than 32-bits will now emit a warning
[[`ce3586da31`](ce3586da31)]
**(SEMVER-MAJOR)** [#15627](#15627)
* **TLS**
* `parseCertString` has been deprecated
[[`468110b327`](468110b327)]
**(SEMVER-MAJOR)** [#14249](#14249)
* Type-checking for `key`, `cert`, and `ca` options has been added
[[`a7dccd040d`](a7dccd040d)]
**(SEMVER-MAJOR)** [#14807](#14807)
@refackrefack removed their assignment Oct 20, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

errorsIssues and PRs related to JavaScript errors originated in Node.js core.semver-majorPRs that contain breaking changes and should be released in the next major version.timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@starkwang@refack@tniessen@BridgeAR@jasnell@thefourtheye@Fishrock123@nodejs-github-bot