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

lib: fix event race condition with -e #11958

Closed
wants to merge 1 commit into from

Commits on Mar 21, 2017

  1. lib: fix event race condition with -e

    Commit c5b07d4 ("lib: fix beforeExit not working with -e") runs the
    to-be-evaluated code at a later time than before because it switches
    from `process.nextTick()` to `setImmediate()`.
    
    It affects `-e 'process.on("message", ...)'` because there is now a
    larger time gap between startup and attaching the event listener,
    increasing the chances of missing early messages.  I'm reasonably
    sure `process.nextTick()` was also susceptible to that, only less
    pronounced.
    
    Avoid the problem altogether by evaluating the code synchronously.
    Harmonizes the logic with `Module.runMain()` from lib/module.js
    which also calls `process._tickCallback()` afterwards.
    bnoordhuis committed Mar 21, 2017
    Configuration menu
    Copy the full SHA
    9d34cc8 View commit details
    Browse the repository at this point in the history