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

test: fix flaky test-async-wrap-uncaughtexception #16598

Closed
wants to merge 1 commit into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Oct 30, 2017

It's possible for beforeExit to be emitted more than once if work is
scheduled by its listeners. Accommodate this fact in the test.

Fixes: #16210

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

test async-wrap

It's possible for `beforeExit` to be emitted more than once if work is
scheduled by its listeners. Accommodate this fact in the test.

Fixes: nodejs#16210
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Oct 30, 2017
@Trott
Copy link
Member Author

Trott commented Oct 30, 2017

ping @joaocgreis @addaleax @joyeecheung I want to make sure this is the correct fix and not working around a legitimate bug in core that needs fixing. See #16210 for background/details.

@Trott
Copy link
Member Author

Trott commented Oct 30, 2017

@Trott
Copy link
Member Author

Trott commented Oct 30, 2017

@nodejs/testing

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

The process.removeAllListeners('uncaughtException'); in L14 can be removed now?

@misterdjules misterdjules mentioned this pull request Oct 30, 2017
2 tasks
@refack refack added the async_hooks Issues and PRs related to the async hooks subsystem. label Oct 30, 2017
Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Not convinced this is the right fix.

@refack
Copy link
Contributor

refack commented Oct 30, 2017

I'm not sure this is the right fix.

  1. This seems like a noop change. If there is a second call to 'uncaughtException' then the process will err-exit anyway.
  2. I'm not sure I understand why this is non-deterministic.

@addaleax
Copy link
Member

I kind of have to side with @refack here – if this is a fix, then it’s not obvious where the second uncaught exception is coming from. From the looks of it, that would not be a bug in the test but rather a bug

@joyeecheung
Copy link
Member

@refack @addaleax Maybe we should just remove the removeAllListeners('uncaughtException') line? If there are more uncaught exceptions(i.e. a bug), the mustCall wrapping the listener would fail. If there are not, not removing the listeners does not block the process from exiting anyway.

@refack
Copy link
Contributor

refack commented Oct 31, 2017

OK so there is definatly a change/regression. Seeing this locally with officialy build binaries:

8.6.0 ✔️

d:\code\node-github-desktop$ node8.6.0 D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js
uncaughtException Error: ah crap
    at RandomBytes.require.randomBytes.common.mustCall (D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js:51:9)
    at RandomBytes.ondone (D:\code\node-github-desktop\test\common\index.js:525:15)
beforeExit
    at process.on (D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js:17:11)
    at emitOne (events.js:115:13)
    at process.emit (events.js:210:7)
RANDOMBYTESREQUEST(5): trigger: 1 execution: 1
before:  5
  Immediate(6): trigger: 5 execution: 5
after:   5
before:  6
after:   6
destroy: 5
destroy: 6

8.7.0 🔴

d:\code\node-github-desktop$ node8.7.0 D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js
uncaughtException Error: ah crap
    at RandomBytes.require.randomBytes.common.mustCall (D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js:51:9)
    at RandomBytes.ondone (D:\code\node-github-desktop\test\common\index.js:525:15)
beforeExit
    at process.on (D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js:17:11)
    at emitOne (events.js:115:13)
    at process.emit (events.js:210:7)
RANDOMBYTESREQUEST(5): trigger: 1 execution: 1
before:  5
  Immediate(6): trigger: 5 execution: 5
after:   5
before:  6
after:   6
destroy: 5
destroy: 6

beforeExit
    at process.on (D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js:17:11)
    at emitOne (events.js:115:13)
    at process.emit (events.js:210:7)
RANDOMBYTESREQUEST(5): trigger: 1 execution: 1
before:  5
  Immediate(6): trigger: 5 execution: 5
after:   5
before:  6
after:   6
destroy: 5
destroy: 6

D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js:20
  if (++count > 1) throw e;
                   ^

Error
    at process.on (D:\code\node-github-desktop\test\parallel\test-async-wrap-uncaughtexception.js:17:11)
    at emitOne (events.js:115:13)
    at process.emit (events.js:210:7)

@Trott
Copy link
Member Author

Trott commented Nov 1, 2017

@refack git bisect to the rescue?

@Trott
Copy link
Member Author

Trott commented Nov 2, 2017

I think I found the commit that is the likely culprit. See #16210 (comment)

Closing this for now.

@Trott Trott closed this Nov 2, 2017
@yhwang yhwang mentioned this pull request Nov 2, 2017
2 tasks
@Trott Trott deleted the fix-flaky-async-wrap branch January 13, 2022 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky test-async-wrap-uncaughtexception
10 participants