Skip to content

Conversation

@addaleax
Copy link
Member

@addaleaxaddaleax commented Jul 14, 2020

In the termination case, we should not crash. There’s also no harm
being done by ignoring the termination exception here, since the
thread is about to be torn down anyway.

Also, add a guard against running this during shutdown. That is the
likely cause of #34361.

Fixes: #34361
Fixes: #27261

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

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol labels Jul 14, 2020
In the termination case, we should not crash. There’s also no harm being done by ignoring the termination exception here, since the thread is about to be torn down anyway. Also, add a guard against running this during shutdown. That is the likely cause of nodejs#34361. Fixes: nodejs#34361
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Jul 15, 2020

@joyeecheung
Copy link
Member

Is there anyway to test this? (I guess this involves shutting down the instance in a particular way so that the inspector agent tries to call into JS when it's not supposed to but I am not sure how that can be triggered with even pummel)

@addaleax
Copy link
MemberAuthor

Yeah, apparently VS Code is able to trigger this but I’m not. If I had a reproduction, I’d add a test here…

@addaleaxaddaleax added the review wanted PRs that need reviews. label Jul 16, 2020
@addaleax
Copy link
MemberAuthor

also /cc @nodejs/inspector


voidAgent::ToggleAsyncHook(Isolate* isolate,
const Global<Function>& fn){
if (!parent_env_->can_call_into_js()) return;
Copy link
Member

Choose a reason for hiding this comment

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

Would be better if some comments are added about when this would happen, maybe something like The inspector agent might attempt to toggle the inspector async hooks to stop tracking async call stacks when the Node.js instance is shutting down and is not supposed to execute JS anymore. To avoid crashing we'll just make it a noop and stop tracking async call stacks here (I am assuming it's fine to just stop tracking because we probably don't care when the instance is shutting down?)

Copy link
Member

@joyeecheungjoyeecheungJul 16, 2020

Choose a reason for hiding this comment

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

Although to quote my comment in #27261 (comment) this still feels like a bug - we are doing inspector client cleanups after the client is being disconnected from the frontend. But I guess a fix like this wouldn't hurt and does the trick for most users which is what matters.

Copy link
Member

Choose a reason for hiding this comment

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

On a side note I think an ultimate fix would be to correct the state management of either waiting_for_frontend_, waiting_for_sessions_disconnect_ or waiting_for_resume_, or add another one to the mix (though I have no idea how)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I’ve added a comment that explains that if we hit this condition, no async events are going to be emitted anyway, and added a link to your comment here 👍

@addaleaxaddaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed review wanted PRs that need reviews. labels Jul 17, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Jul 21, 2020

@addaleax
Copy link
MemberAuthor

Landed in 687dbd8

addaleax added a commit that referenced this pull request Jul 21, 2020
In the termination case, we should not crash. There’s also no harm being done by ignoring the termination exception here, since the thread is about to be torn down anyway. Also, add a guard against running this during shutdown. That is the likely cause of #34361. Fixes: #34361 PR-URL: #34362Fixes: #27261 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
@addaleaxaddaleax deleted the inspector-no-bail-on-termination branch July 21, 2020 23:13
cjihrig pushed a commit that referenced this pull request Jul 23, 2020
In the termination case, we should not crash. There’s also no harm being done by ignoring the termination exception here, since the thread is about to be torn down anyway. Also, add a guard against running this during shutdown. That is the likely cause of #34361. Fixes: #34361 PR-URL: #34362Fixes: #27261 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 27, 2020
In the termination case, we should not crash. There’s also no harm being done by ignoring the termination exception here, since the thread is about to be torn down anyway. Also, add a guard against running this during shutdown. That is the likely cause of #34361. Fixes: #34361 PR-URL: #34362Fixes: #27261 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
@ruyadornoruyadorno mentioned this pull request Jul 28, 2020
addaleax added a commit that referenced this pull request Aug 13, 2020
In the termination case, we should not crash. There’s also no harm being done by ignoring the termination exception here, since the thread is about to be torn down anyway. Also, add a guard against running this during shutdown. That is the likely cause of #34361. Fixes: #34361 PR-URL: #34362Fixes: #27261 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
@codebyterecodebytere mentioned this pull request Sep 28, 2020
jimmy54 pushed a commit to jimmy54/nodejs-mobile that referenced this pull request Dec 31, 2025
In the termination case, we should not crash. There’s also no harm being done by ignoring the termination exception here, since the thread is about to be torn down anyway. Also, add a guard against running this during shutdown. That is the likely cause of nodejs/node#34361. Fixes: nodejs/node#34361 PR-URL: nodejs/node#34362Fixes: nodejs/node#27261 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs 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++.inspectorIssues and PRs related to the V8 inspector protocol

Projects

None yet

Development

Successfully merging this pull request may close these issues.

illegal access error with Typescript compiled code Node fatal error: ToggleAsyncHook Cannot toggle Inspector's AsyncHook

6 participants

@addaleax@nodejs-github-bot@joyeecheung@jasnell@devsnek@MylesBorins