Skip to content

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

Closed
Trott wants to merge 1 commit into
nodejs:masterfrom
Trott:fix-flaky-async-wrap
Closed

test: fix flaky test-async-wrap-uncaughtexception#16598
Trott wants to merge 1 commit into
nodejs:masterfrom
Trott:fix-flaky-async-wrap

Conversation

@Trott

Copy link
Copy Markdown
Member

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-botnodejs-github-bot added the test Issues and PRs related to the tests. label Oct 30, 2017
@Trott

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

@Trott

Copy link
Copy Markdown
MemberAuthor

@nodejs/testing

@joyeecheungjoyeecheung left a comment

Copy link
Copy Markdown
Member

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?

@misterdjulesmisterdjules mentioned this pull request Oct 30, 2017
2 tasks
@refackrefack added the async_hooks Issues and PRs related to the async hooks subsystem. label Oct 30, 2017

@refackrefack left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@refack

refack commented Oct 31, 2017

Copy link
Copy Markdown
Contributor

@refack

Copy link
Copy Markdown
Contributor

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

Trott commented Nov 1, 2017

Copy link
Copy Markdown
MemberAuthor

@refackgit bisect to the rescue?

@Trott

Trott commented Nov 2, 2017

Copy link
Copy Markdown
MemberAuthor

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

Closing this for now.

@TrottTrott closed this Nov 2, 2017
@yhwangyhwang 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

async_hooksIssues and PRs related to the async hooks subsystem.testIssues 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

@Trott@refack@addaleax@joyeecheung@apapirovski@danbev@jasnell@cjihrig@mscdex@nodejs-github-bot