Skip to content
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

inspector: display error when ToggleAsyncHook fails #26859

Closed
wants to merge 1 commit into from

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Mar 22, 2019

This patch refactors AppendExceptionLine and PrintSyncTrace
to reuse the error formatting logic and use them to print
uncaught error in ``ToggleAsyncHook`

Refs: #26798

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Mar 22, 2019
@joyeecheung
Copy link
Member Author

@joyeecheung
Copy link
Member Author

00:28:08     [err] async_hooks.js:32
00:28:08     [err]   async_id_symbol, trigger_async_id_symbol,
00:28:08     [err]   ^
00:28:08     [err] 
00:28:08     [err] TypeError: Cannot destructure property `async_id_symbol` of 'undefined' or 'null'.
00:28:08     [err]     at async_hooks.js:31:7
00:28:08     [err]     at NativeModule.compile (internal/bootstrap/loaders.js:300:5)
00:28:08     [err]     at nativeModuleRequire (internal/bootstrap/loaders.js:188:14)
00:28:08     [err]     at lazyHookCreation (internal/inspector_async_hook.js:8:26)
00:28:08     [err]     at enable (internal/inspector_async_hook.js:47:27)
00:28:08     [err]     at internal/async_hooks.js:1:1
00:28:08     [err]     at NativeModule.compile (internal/bootstrap/loaders.js:300:5)
00:28:08     [err]     at nativeModuleRequire (internal/bootstrap/loaders.js:188:14)
00:28:08     [err]     at internal/process/task_queues.js:31:5
00:28:08     [err]     at NativeModule.compile (internal/bootstrap/loaders.js:300:5)
00:28:08     [err]     at nativeModuleRequire (internal/bootstrap/loaders.js:188:14)

From the CI

@joyeecheung
Copy link
Member Author

Looks like it's yet another circular dependency issue

@joyeecheung
Copy link
Member Author

Try to see more traces by setting Error.stackTraceLimit = Infinity; https://ci.nodejs.org/job/node-stress-single-test/2182

@joyeecheung
Copy link
Member Author

joyeecheung commented Mar 22, 2019

er, this is interesting, setting Error.stackTraceLimit = Infinity results in 100% failure with a new one filling the rest of the cases

EDIT: oh, I was being silly, the line number changed.

@joyeecheung
Copy link
Member Author

joyeecheung commented Mar 22, 2019

@joyeecheung
Copy link
Member Author

Looks like it's too late to set Error.stackTraceLimit = Infinity in user code. Trying another approach..

https://ci.nodejs.org/job/node-stress-single-test/2184/

@joyeecheung
Copy link
Member Author

Let's see if moving setupHooks makes a difference (if not, then setupHooks is not the key here). https://ci.nodejs.org/job/node-stress-single-test/2192/

@joyeecheung
Copy link
Member Author

setupHooks is not the key here. Or maybe it needs to enter the context first..https://ci.nodejs.org/job/node-stress-single-test/2193/

refack pushed a commit to joyeecheung/node that referenced this pull request Mar 23, 2019
Otherwise the exports of `internal/async_hooks` may be undefined
when the inspector async hooks are registered.

PR-URL: nodejs#26866
Fixes: nodejs#26798
Refs: nodejs#26859
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
@BridgeAR BridgeAR added the wip Issues and PRs that are still a work in progress. label Mar 25, 2019
@joyeecheung joyeecheung force-pushed the display-message branch 3 times, most recently from fd8dc54 to 1fcb78c Compare March 26, 2019 19:23
This patch refactors `AppendExceptionLine` and `PrintSyncTrace`
to reuse the error formatting logic and use them to print
uncaught error in ``ToggleAsyncHook`
@joyeecheung joyeecheung removed the wip Issues and PRs that are still a work in progress. label Mar 26, 2019
@nodejs-github-bot
Copy link
Collaborator

@joyeecheung
Copy link
Member Author

cc @nodejs/v8-inspector @nodejs/async_hooks

Removed the investigation code and made it a patch that prints more information when ToggleAsyncHook fails. I'd like to land this to investigate #26798 further.

(We could probably reuse PrintCaughtException through out the code base to print more stuff before hard crash on JS errors)

@mcollina
Copy link
Member

@joyeecheung does this change functionality? display error when ToggleAsyncHook fails seems it adds a new feature, but I don't see any tests added.

@mcollina
Copy link
Member

@joyeecheung does this change functionality? display error when ToggleAsyncHook fails seems it adds a new feature, but I don't see any tests added. It also seems a refactoring and not a change in functionality, so maybe the commit message is not correct.

Code looks ok to me.

@joyeecheung
Copy link
Member Author

joyeecheung commented Mar 27, 2019

@mcollina No, the error only shows up when there is a bug (see the referenced flaky test), and it will crash the process immediately, this just prints more information to stderr before crashing to facilitate debugging. I don’t think tests can be added (the internals affected are not even monkey patchable since it’s done before any user code execution)

ToggleAsyncHook is an internal C++ function, not accessible in the user land so I don’t think the message implies it changes functionality?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 27, 2019
targos pushed a commit to targos/node that referenced this pull request Mar 27, 2019
Otherwise the exports of `internal/async_hooks` may be undefined
when the inspector async hooks are registered.

PR-URL: nodejs#26866
Fixes: nodejs#26798
Refs: nodejs#26859
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
targos pushed a commit that referenced this pull request Mar 27, 2019
Otherwise the exports of `internal/async_hooks` may be undefined
when the inspector async hooks are registered.

PR-URL: #26866
Fixes: #26798
Refs: #26859
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
@joyeecheung
Copy link
Member Author

Landed in 61ef9df

pull bot pushed a commit to zys-contrib/node that referenced this pull request Mar 30, 2019
This patch refactors `AppendExceptionLine` and `PrintSyncTrace`
to reuse the error formatting logic and use them to print
uncaught error in ``ToggleAsyncHook`

PR-URL: nodejs#26859
Refs: nodejs#26798
Reviewed-By: Matteo Collina <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 5, 2019
This patch refactors `AppendExceptionLine` and `PrintSyncTrace`
to reuse the error formatting logic and use them to print
uncaught error in ``ToggleAsyncHook`

PR-URL: #26859
Refs: #26798
Reviewed-By: Matteo Collina <[email protected]>
BethGriggs pushed a commit that referenced this pull request Apr 8, 2019
This patch refactors `AppendExceptionLine` and `PrintSyncTrace`
to reuse the error formatting logic and use them to print
uncaught error in ``ToggleAsyncHook`

PR-URL: #26859
Refs: #26798
Reviewed-By: Matteo Collina <[email protected]>
Signed-off-by: Beth Griggs <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants