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: replace flaky immediates event loop test #41423

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ prefix parallel
test-repl-sigint-nested-eval: PASS, FLAKY

[$system==win32]
# https://github.com/nodejs/node/issues/24497
test-timers-immediate-queue: PASS,FLAKY
# https://github.com/nodejs/node/issues/23277
test-worker-memory: PASS,FLAKY
# https://github.com/nodejs/node/issues/41206
Expand Down
34 changes: 34 additions & 0 deletions test/parallel/test-timers-immediate-event-loop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Flags: --expose-internals
'use strict';

const common = require('../common');

const assert = require('assert');
const { sleep } = require('internal/util');

// SetImmediate should clear its existing queue on each event loop run
// but leave any newly scheduled Immediates until the next run.
//
// Since timer expiries are notoriously flaky and dependant on specific
// OS configurations, we instead just check that an Immediate queue
// will eventually be interrupted by the timer — regardless of how long
// it actually takes for that to happen.

const duration = 1;
let nextImmediate;

const exit = common.mustCall(() => {
assert.ok(nextImmediate.hasRef());
process.exit();
});

function check() {
sleep(duration);
nextImmediate = setImmediate(check);
}

setImmediate(common.mustCall(() => {
setTimeout(exit, duration);

check();
}));
57 changes: 0 additions & 57 deletions test/parallel/test-timers-immediate-queue.js

This file was deleted.