Skip to content

errors, process: port internal/process errors to internal/errors - #11294

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

errors, process: port internal/process errors to internal/errors#11294
jasnell wants to merge 1 commit into
nodejs:masterfrom
jasnell:internal-errors-1

Conversation

@jasnell

Copy link
Copy Markdown
Member
  • Assign codes to the handful of errors reported by internal/process/*.js
  • Include documentation for the new error codes
  • Improve error messages
  • Improve test coverage for process.nextTick

Ref: #11273

Semver-major because this updates specific error messages and converts errors over to use the new internal/errors.js mechanism.

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)

errors, process

@jasnelljasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Feb 10, 2017
@nodejs-github-botnodejs-github-bot added the errors Issues and PRs related to JavaScript errors originated in Node.js core. label Feb 10, 2017
@mscdexmscdex added the process Issues and PRs related to the process subsystem. label Feb 10, 2017
Comment threaddoc/api/errors.md 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.

(Not sure which PR is the right place to ask, this one seems the oldest so I'll ask here)

Which one does the "type" here cover:

  • Primitive types (i.e. typeof types, doesn't differentiate Date and RegExp and stuff)
  • Builtin type tags(i.e. results of Object.prototype.toString.call(), differentiates Date and RegExp)
  • Class mismatch(i.e. instanceof types, differentiates Date and RegExp)

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.

Also, some PRs use the typeof types as the expected type(e.g. "function"), some uses the class name/type tag(e.g. "Object"), we probably need to be a little bit consistent on this one.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This is not handled very consistently throughout the Node.js source. Sometimes the value itself is passed in, sometimes the typeof is used, etc. The goal here would be to start getting some consistency but it's hard to nail down exactly what that should be.

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.

Got it, so we should focus on migrating the errors to use the new system with a reasonable code right now, and deal with message later, because after the migration it would be easier to change them anyway?

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.

String(..) seems unnecessary here?

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.

+1. It's already cast on line 103

@jasnell

Copy link
Copy Markdown
MemberAuthor

@nodejs/ctc ... as a semver major this needs some review and signoff

@jasnell

Copy link
Copy Markdown
MemberAuthor

@bougarfaouibougarfaoui left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@jasnell in the invalidArgType : what if the actual arg is null , the result will be . Received type object

@jasnell

Copy link
Copy Markdown
MemberAuthor

Sigh, good point. I often forget that typeof null === 'object' which is really quite odd.

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.

#11298 spells the full UNKNOWN, this should do the same (TBH I can not understand what UNK stands for at first glance...).

@jasnell
jasnellforce-pushed the internal-errors-1 branch 3 times, most recently from 7f1def6 to 86c7993CompareFebruary 16, 2017 20:24
@jasnell

Copy link
Copy Markdown
MemberAuthor

@nodejs/ctc ... PTAL... I'd like to get this landed so we can start getting through the others that are starting to stack up

@jasnell

Copy link
Copy Markdown
MemberAuthor

ping @evanlucas, @addaleax, @cjihrig and @mhdawson

@jasnell

Copy link
Copy Markdown
MemberAuthor

@nodejs/ctc ... I need at least one more CTC member sign off on this to proceed.

@evanlucas

Copy link
Copy Markdown
Contributor

As I mentioned somewhere else (not sure where, there have been a bunch of these pull requests), I'm not thrilled with what the stack trace looks like after this change.

@jasnell

Copy link
Copy Markdown
MemberAuthor

Which part are you unhappy with?

@evanlucas

Copy link
Copy Markdown
Contributor
$./node--expose-internals>newerrors.Error('ERR_ASSERTION','something'){Error[ERR_ASSERTION]: somethingat repl:1:1atContextifyScript.Script.runInThisContext(vm.js:44:33)atREPLServer.defaultEval(repl.js:239:29)atbound(domain.js:301:14)atREPLServer.runBound[aseval](domain.js:314:12)atREPLServer.onLine(repl.js:433:10)atemitOne(events.js:120:20)atREPLServer.emit(events.js:210:7)atREPLServer.Interface._onLine(readline.js:262:10)atREPLServer.Interface._line(readline.js:611:8)[Symbol(code)]: 'ERR_ASSERTION'}

I just find it a little harder to read Error[ERR_ASSERTION]: in particular. As opposed to Error:

@jasnell

Copy link
Copy Markdown
MemberAuthor

Do you have an alternative suggestion? Displaying the error code in the output is a significant reason why this allows us to avoid treating changes in the error message as semver-major... That is, it gives the user a stable, non-changing key they can use to search for information on the specific error. Putting the [ERR_ASSERTION] on the other side of the : requires changing the actual error message.

@Trott

Copy link
Copy Markdown
Member

As I mentioned somewhere else (not sure where, there have been a bunch of these pull requests), I'm not thrilled with what the stack trace looks like after this change.

I can't find it either, but I chimed in on that too. Error[ERR_ASSERTION] looks like an array value. At an absolute minimum, please put a space in there: Error [ERR_ASSERTION]:

If @evanlucas's output is accurate, the { and } surrounding the output should also be removed. They suggest the contents are an object or JSON.

@jasnell

Copy link
Copy Markdown
MemberAuthor

The { and } is an artifact of util.inspect() rendering, not the internal errors piece.... for instance, do

>varm=newError("test")undefined>m.code=11>m{ Error: test
at repl:1:9atContextifyScript.Script.runInThisContext(vm.js:44:33)atREPLServer.defaultEval(repl.js:239:29)atbound(domain.js:301:14)atREPLServer.runBound[aseval](domain.js:314:12)atREPLServer.onLine(repl.js:433:10)atemitOne(events.js:120:20)atREPLServer.emit(events.js:210:7)atREPLServer.Interface._onLine(readline.js:262:10)atREPLServer.Interface._line(readline.js:611:8) code: 1}

I will open a PR that adds the space before the opening [

@gibfahn

gibfahn commented Mar 28, 2017

Copy link
Copy Markdown
Member

I will open a PR that adds the space before the opening [

PR: #12099

@jasnell

Copy link
Copy Markdown
MemberAuthor

Ping @nodejs/ctc ... I'd like to get this landed. Before the other errors ones get landed.

@Trott

Trott commented Apr 5, 2017

Copy link
Copy Markdown
Member

@jasnell This needs at least one more CTC approval before landing. Maybe you can horse-trade with @trevnorris: You review his async-hooks PR that he's not getting enough reviews on and in return he reviews this.

I'm kidding. Or am I?

@jasnell

Copy link
Copy Markdown
MemberAuthor

I'd review the async-hooks had I the time. It's a large pr. I can take a look next week. There are quite a few other prs pending on this one, all semver major, that I would like to get landed

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.

Maybe break out the expected.slice().join() into a variable? It is getting a little hard to read imo.

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.

With only the first three arguments being used, maybe make this if (arguments.length === 3) {?

Feel free to disregard

@jasnell

Copy link
Copy Markdown
MemberAuthor

@evanlucas ... do you still object to this?

@evanlucas

Copy link
Copy Markdown
Contributor

@jasnell my review was not an objection. I think I'm onboard with this now.

@jasnell

Copy link
Copy Markdown
MemberAuthor

Awesome, ok. Can I ask you to switch the "requested changes" to an approval or LGTM so I can get this landed. As a semver-major I need two CTC signoffs :-)

* Assign codes to the handful of errors reported by
internal/process/*.js
* Include documentation for the new error codes
* Improve error messages
* Improve test coverage for process.nextTick
Ref: nodejs#11273
@jasnell

Copy link
Copy Markdown
MemberAuthor

@jasnell

Copy link
Copy Markdown
MemberAuthor

CI failures are unrelated. Failures in CITGM are not specific to this PR.

jasnell added a commit that referenced this pull request Apr 20, 2017
* Assign codes to the handful of errors reported by
internal/process/*.js
* Include documentation for the new error codes
* Improve error messages
* Improve test coverage for process.nextTick
PR-URL: #11294
Ref: #11273
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
@jasnell

Copy link
Copy Markdown
MemberAuthor

Landed in e75bc87

@jasnelljasnell closed this Apr 20, 2017
@jasnelljasnell mentioned this pull request May 11, 2017
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.processIssues and PRs related to the process subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@jasnell@evanlucas@Trott@gibfahn@targos@joyeecheung@bougarfaoui@mscdex@refack@nodejs-github-bot