GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — worker: fix exit code for error thrown in uncaughtException handler by Linkgoron · Pull Request #38012 · nodejs/node

Conversation

@Linkgoron

@Linkgoron Linkgoron commented Mar 31, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

When an uncaughtException handler itself throws in a worker, the worker exits with an error code of 0 instead of 7 1, which happens because the worker thread global handler catches the error, and exitCode stays 0.

My fix only emits exit for "regular" unhandled exceptions (which shouldn't actually reach that code anyway, as it should set _exiting correctly in the "inner" handler) to emulate the same behaviour that happens in non-workers, where exit is not emitted when an error is thrown from a handler.

The process._exiting logic was essentially taken from here: https://github.com/nodejs/node/blob/master/lib/internal/process/execution.js#L167

Fixes: #37996

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Mar 31, 2021
@Linkgoron Linkgoron changed the title worker: fix exit code for error thrown in unhandled handler worker: fix exit code for error thrown in uncaughtException handler Mar 31, 2021
@Linkgoron
worker: fix exit code for error thrown in handler
7cf8425
Change worker exit code when the unhandled exception
handler throws from 0 to 7

fixes: nodejs#37996
@Linkgoron
Linkgoron force-pushed the worker-throw-in-unhandled-exception branch from ddcff99 to 7cf8425 Compare March 31, 2021 23:04
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@Prinzhorn

Prinzhorn commented Apr 1, 2021

Copy link
Copy Markdown

Thanks for fixing this so quickly. I think the docs need an update as well if we're going with 7 and not 1

If the worker was terminated, the exitCode parameter is 1.

https://nodejs.org/api/worker_threads.html#worker_threads_event_exit

Linkgoron reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Linkgoron
fixup! worker: fix exit code for error thrown in handler
aa0c09d
@Linkgoron

Linkgoron commented Apr 1, 2021

Copy link
Copy Markdown
Contributor Author

I've changed the exit code to 1 to conform with the documentation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

This comment has been minimized.

Sign in to view
@Linkgoron
fixup! fixup! worker: fix exit code for error thrown in handler
7779d71
@Linkgoron
Linkgoron force-pushed the worker-throw-in-unhandled-exception branch from 287f22e to 7779d71 Compare April 1, 2021 11:23
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@Linkgoron Linkgoron added the worker Issues and PRs related to the worker_threads module and Worker API. label Apr 3, 2021
@Linkgoron

Linkgoron commented Apr 3, 2021

Copy link
Copy Markdown
Contributor Author

@nodejs/workers

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr approved these changes Apr 3, 2021
View reviewed changes
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@Linkgoron Linkgoron added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Apr 5, 2021
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@nodejs-github-bot

nodejs-github-bot commented Apr 6, 2021 •
edited by jasnell
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/37206/ 💚

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Apr 6, 2021
View reviewed changes
jasnell pushed a commit that referenced this pull request Apr 6, 2021
@Linkgoron @jasnell
worker: fix exit code for error thrown in handler
6986fa0
Change worker exit code when the unhandled exception
handler throws from 0 to 7

fixes: #37996

PR-URL: #38012
Fixes: #37996
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@jasnell

jasnell commented Apr 6, 2021

Copy link
Copy Markdown
Member

Landed in 6986fa0

Linkgoron reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell closed this Apr 6, 2021
@Prinzhorn

Prinzhorn commented Apr 7, 2021

Copy link
Copy Markdown

thanks!

Landed in 6986fa0

The 7 slipped in there again "from 0 to 7"

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Linkgoron

Linkgoron commented Apr 7, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

thanks!

Landed in 6986fa0

The 7 slipped in there again "from 0 to 7"

Yeah, it looks like I missed amending the commit message. The PR is good though, and correctly exits with 1.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BethGriggs BethGriggs mentioned this pull request Apr 12, 2021
2021-04-20, Version 16.0.0 (Current) #37678
Merged
targos pushed a commit that referenced this pull request May 1, 2021
@Linkgoron @targos
worker: fix exit code for error thrown in handler
b6f4d79
Change worker exit code when the unhandled exception
handler throws from 0 to 7

fixes: #37996

PR-URL: #38012
Fixes: #37996
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@danielleadams danielleadams mentioned this pull request May 3, 2021
v14.17.0 proposal #38507
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@benjamingr benjamingr benjamingr approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. needs-ci PRs that need a full CI run. worker Issues and PRs related to the worker_threads module and Worker API.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Worker exits with code 0 (and not 7) when throwing inside uncaughtException

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Linkgoron @nodejs-github-bot @Prinzhorn @jasnell @benjamingr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.