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

events: migrate to internal/errors #15623

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
6 participants
@jasnell
Member

jasnell commented Sep 26, 2017

Migrate events.js to internal errors

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

events,errors

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell
Member

jasnell commented Sep 26, 2017

@joyeecheung

Left a few nits. LGTM if CI is green.

Show outdated Hide outdated doc/api/errors.md Outdated
Show outdated Hide outdated lib/events.js Outdated
@joyeecheung

This comment has been minimized.

Show comment
Hide comment
Member

joyeecheung commented Sep 26, 2017

Show outdated Hide outdated lib/events.js Outdated
if (typeof listener !== 'function')
throw new TypeError('"listener" argument must be a function');
if (typeof listener !== 'function') {
const errors = lazyErrors();

This comment has been minimized.

@BridgeAR

BridgeAR Sep 26, 2017

Member

Do you know where the circular reference is coming from? If so - is there any possibility in untying that?
I personally also prefer using a simple if a lot over the function version. It is still a minor overhead of using the function while there is no faster check than a simple if to undefined.

@BridgeAR

BridgeAR Sep 26, 2017

Member

Do you know where the circular reference is coming from? If so - is there any possibility in untying that?
I personally also prefer using a simple if a lot over the function version. It is still a minor overhead of using the function while there is no faster check than a simple if to undefined.

This comment has been minimized.

@jasnell

jasnell Sep 26, 2017

Member

It's not a circular reference that is the concern. The events module is one of the very first modules loaded in core (because it is needed by process) and as such needs to be loaded before anything else is loaded.

@jasnell

jasnell Sep 26, 2017

Member

It's not a circular reference that is the concern. The events module is one of the very first modules loaded in core (because it is needed by process) and as such needs to be loaded before anything else is loaded.

Show outdated Hide outdated lib/events.js Outdated
Show outdated Hide outdated doc/api/errors.md Outdated
Show outdated Hide outdated lib/internal/errors.js Outdated
Show outdated Hide outdated test/parallel/test-event-emitter-max-listeners.js Outdated
@BridgeAR

The obsolete error code should be removed. LGTM otherwise (I do not feel that strongly about the more generic name even if I would still prefer it without "EVENTS").

Show outdated Hide outdated doc/api/errors.md Outdated
Show outdated Hide outdated doc/api/errors.md Outdated

@jasnell jasnell referenced this pull request Sep 28, 2017

Closed

Tracking Issue: Migrate errors to internal/errors.js #11273

78 of 80 tasks complete
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Oct 2, 2017

Member

@BridgeAR .. updated.
@nodejs/tsc PTAL

Member

jasnell commented Oct 2, 2017

@BridgeAR .. updated.
@nodejs/tsc PTAL

@jasnell jasnell requested a review from nodejs/tsc Oct 2, 2017

@mhdawson

This change looks good, but I think we need to add a test for the new error in test/parallel/test-internal-errors.js

if (errors === undefined)
errors = require('internal/errors');
return errors;
}

This comment has been minimized.

@mcollina

mcollina Oct 6, 2017

Member

Why do we need to lazily load this? Is this the pattern used everywhere? Should we?

@mcollina

mcollina Oct 6, 2017

Member

Why do we need to lazily load this? Is this the pattern used everywhere? Should we?

This comment has been minimized.

@jasnell

jasnell Oct 9, 2017

Member

It is because events.js is loaded before all the other modules in the dependency tree (because of bootstrapping process. Lazy loading errors prevents errors from being loaded before events is loaded.

@jasnell

jasnell Oct 9, 2017

Member

It is because events.js is loaded before all the other modules in the dependency tree (because of bootstrapping process. Lazy loading errors prevents errors from being loaded before events is loaded.

This comment has been minimized.

@BridgeAR

BridgeAR Oct 10, 2017

Member

I would still rather inline this instead of using the function form but it should not be a blocker.

@BridgeAR

BridgeAR Oct 10, 2017

Member

I would still rather inline this instead of using the function form but it should not be a blocker.

@mcollina

LGTM

@mcollina

This comment has been minimized.

Show comment
Hide comment
@mcollina

mcollina Oct 10, 2017

Member

@BridgeAR are you ok with the change? Can we land?

Member

mcollina commented Oct 10, 2017

@BridgeAR are you ok with the change? Can we land?

@joyeecheung

This comment has been minimized.

Show comment
Hide comment
@joyeecheung

This comment has been minimized.

Show comment
Hide comment
@joyeecheung

joyeecheung Oct 10, 2017

Member

Would be better if we can specify the range with ERR_OUT_OF_RANGE, that can be done later in another PR.

Member

joyeecheung commented Oct 10, 2017

Would be better if we can specify the range with ERR_OUT_OF_RANGE, that can be done later in another PR.

{
code: 'ERR_UNHANDLED_ERROR',
type: Error,
message: 'Unhandled error. (Accepts a string)'

This comment has been minimized.

@BridgeAR

BridgeAR Oct 10, 2017

Member

The message looks somewhat weird here because of the dot before the brackets.
I think it would be fine to either remove the dot or to move it to the end of the string.

@BridgeAR

BridgeAR Oct 10, 2017

Member

The message looks somewhat weird here because of the dot before the brackets.
I think it would be fine to either remove the dot or to move it to the end of the string.

if (errors === undefined)
errors = require('internal/errors');
return errors;
}

This comment has been minimized.

@BridgeAR

BridgeAR Oct 10, 2017

Member

I would still rather inline this instead of using the function form but it should not be a blocker.

@BridgeAR

BridgeAR Oct 10, 2017

Member

I would still rather inline this instead of using the function form but it should not be a blocker.

@BridgeAR

This comment has been minimized.

Show comment
Hide comment
@BridgeAR

BridgeAR Oct 10, 2017

Member

@mcollina thanks for the ping

Member

BridgeAR commented Oct 10, 2017

@mcollina thanks for the ping

jasnell added a commit that referenced this pull request Oct 13, 2017

events: migrate to internal/errors
PR-URL: #15623
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Oct 13, 2017

Member

Landed in e5ad545

Member

jasnell commented Oct 13, 2017

Landed in e5ad545

@jasnell jasnell closed this Oct 13, 2017

@starkwang starkwang referenced this pull request Oct 15, 2017

Closed

lib: move duplicate spliceOne into internal/util #16221

2 of 2 tasks complete

addaleax added a commit to ayojs/ayo that referenced this pull request Oct 15, 2017

events: migrate to internal/errors
PR-URL: nodejs/node#15623
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment