-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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_runner: bootstrap reporters before running tests #46737
Conversation
Review requested:
|
This comment was marked as outdated.
This comment was marked as outdated.
@nodejs/test_runner this only solves one issue, there seems to be another issue with the process not being alive long enough to pipe the entire stream, see
I am trying to work on the additional issue on a separate PR |
Should we wait for the child process's |
once the child process is not alive, transforming the output asynchronously is not enough for keeping the main process alive I have solved that like this: @@ -123,13 +125,16 @@ function setup(root) {
const rejectionHandler =
createProcessEventHandler('unhandledRejection', root);
const coverage = configureCoverage(root);
- const exitHandler = () => {
+ const exitHandler = async () => {
root.coverage = collectCoverage(root, coverage);
root.postRun(new ERR_TEST_FAILURE(
'Promise resolution is still pending but the event loop has already resolved',
kCancelledByParent));
hook.disable();
+ const handle = setInterval(() => {}, 1000);
+ await finished(root.reporter);
+ clearInterval(handle);
process.removeListener('unhandledRejection', rejectionHandler);
process.removeListener('uncaughtException', exceptionHandler);
}; but that is kind of a hack |
if anyone wants to tackle this it reproduces running |
Interestingly, I haven't been able to get it to reproduce on my machine (M1 mac).
Definitely a hack, but if there is no way to keep the process alive, I'd be OK with doing something like that, but I think it should exist in |
Mine is a M1 mac as well 😕 |
@cjihrig I have tried that but it creates a deadlock - adding a timer prevents the process from reaching |
afc52f4
to
6a24768
Compare
lib/internal/test_runner/test.js
Outdated
// In case the event loop has ended and reporter has not drained, | ||
// we use a timer to keep the process alive until the reporter is done. | ||
const handle = setInterval(() => {}, TIMEOUT_MAX); | ||
this.reporter.once('close', () => clearInterval(handle)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the stream still working but not keeping the process alive? Is there a resource somewhere that we unref()
d ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #22088 (comment)
the reporters transform the output after the child process are done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, do we have any idea which change introduced the current flakiness? After the CI was unlocked from the security release, a flurry of changes landed and then this test became flaky. Are we able to bisect it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am bisecting now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjihrig according to git bisect flakiness started after b4a962d landed, so it would have probably become flaky even without the latest test runner changes.
CC @debadree25 @nodejs/streams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, investigating then, could you guide me if at any place in the test_runner code where pipeline maybe being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the timing condition we might be facing is within setupTestReporters
where getReportersMap
is fulfilled after all the tests completed running
node/lib/internal/test_runner/utils.js
Lines 151 to 158 in 5e954c3
async function setupTestReporters(testsStream) { | |
const { reporters, destinations } = parseCommandLine(); | |
const reportersMap = await getReportersMap(reporters, destinations); | |
for (let i = 0; i < reportersMap.length; i++) { | |
const { reporter, destination } = reportersMap[i]; | |
compose(testsStream, reporter).pipe(destination); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah understood, thank you checking this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record: I think the issue is in the test runner, not in change performed to streams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far no success in thinking with reference to b4a962d only think that comes to mind is if anyway testsStream ended before somehow? but that also doesn't hold up much 😕 nonetheless will try explore a little more just incase
6a24768
to
6ea5d9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if the CI passes - definitely nicer than adding a keep alive timer.
d92b981
to
d326348
Compare
Commit Queue failed- Loading data for nodejs/node/pull/46737 ✔ Done loading data for nodejs/node/pull/46737 ----------------------------------- PR info ------------------------------------ Title test_runner: bootstrap reporters before running tests (#46737) Author Moshe Atlow (@MoLow) Branch MoLow:wait-for-parser-to-finish -> nodejs:main Labels flaky-test, author ready, needs-ci, dont-land-on-v14.x, test_runner Commits 1 - test_runner: bootstrap reporters before running tests Committers 1 - Moshe Atlow PR-URL: https://github.com/nodejs/node/pull/46737 Fixes: https://github.com/nodejs/node/issues/46747 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/46737 Fixes: https://github.com/nodejs/node/issues/46747 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig -------------------------------------------------------------------------------- ℹ This PR was created on Sun, 19 Feb 2023 19:16:17 GMT ✔ Approvals: 2 ✔ - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/46737#pullrequestreview-1308076791 ✔ - Colin Ihrig (@cjihrig) (TSC): https://github.com/nodejs/node/pull/46737#pullrequestreview-1307932394 ✖ GitHub CI is still running ℹ Last Full PR CI on 2023-02-21T19:30:15Z: https://ci.nodejs.org/job/node-test-pull-request/49848/ - Querying data for job/node-test-pull-request/49848/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/4236769504 |
PR-URL: #46737 Fixes: #46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Landed in ce49f79 |
PR-URL: nodejs#46737 Fixes: nodejs#46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: nodejs#46737 Fixes: nodejs#46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: nodejs#46737 Fixes: nodejs#46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #46737 Backport-PR-URL: #46839 Fixes: #46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #46737 Backport-PR-URL: #46839 Fixes: #46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #46737 Fixes: #46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #46737 Fixes: #46747 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Fixes: #46747
I believe this will address these test failures:
https://ci.nodejs.org/job/node-test-binary-windows-js-suites/19156/