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

worker: move JoinThread() back into exit callback #31468

Closed
wants to merge 2 commits into from

Commits on Jan 22, 2020

  1. worker: move JoinThread() back into exit callback

    de2c68c moved this call to
    the destructor, under the assumption that that would essentially
    be equivalent to running it as part of the callback since the
    worker would be destroyed along with the callback.
    
    However, the actual code in
    `Environment::RunAndClearNativeImmediates()` comes with the subtlety
    that testing whether a JS exception has been thrown
    happens between the invocation of the callback and its destruction,
    leaving a possible exception from `JoinThread()` potentially
    unhandled (and unintentionally silenced through the `TryCatch`).
    
    This affected exceptions thrown from the `'exit'` event of the
    Worker, and made the `parallel/test-worker-message-type-unknown`
    test flaky, as the invalid message was sometimes only received
    during the Worker thread’s exit handler.
    
    Fix this by moving the `JoinThread()` call back to where it was
    before.
    
    Refs: nodejs#31386
    addaleax committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    d55fac1 View commit details
    Browse the repository at this point in the history
  2. src: harden running native SetImmediate()s slightly

    Prevent mistakes like the one fixed by the previous commit
    by destroying the callback immediately after it has been called.
    addaleax committed Jan 22, 2020
    Configuration menu
    Copy the full SHA
    ff3cd57 View commit details
    Browse the repository at this point in the history