GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: improve abort signal dropping test · nodejs/node@64556ba

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-abortsignal-drop-settled-signals.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-abortsignal-drop-settled-signals.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-abortsignal-drop-settled-signals.mjs
+17-12Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,30 @@ it('does not prevent source signal from being GCed if it is short-lived', (t, do
134134

135135
it('drops settled dependant signals when signal is composite', (t, done) => {
136136
const controllers = Array.from({ length: 2 }, () => new AbortController());
137-
const composedSignal1 = AbortSignal.any([controllers[0].signal]);
138-
const composedSignalRef = new WeakRef(AbortSignal.any([composedSignal1, controllers[1].signal]));
137+
138+
// Using WeakRefs to avoid this test to retain information that will make the test fail
139+
const composedSignal1 = new WeakRef(AbortSignal.any([controllers[0].signal]));
140+
const composedSignalRef = new WeakRef(AbortSignal.any([composedSignal1.deref(), controllers[1].signal]));
139141

140142
const kDependantSignals = Object.getOwnPropertySymbols(controllers[0].signal).find(
141143
(s) => s.toString() === 'Symbol(kDependantSignals)'
142144
);
143145

144-
setImmediate(() => {
145-
global.gc({ execution: 'async' }).then(() => {
146-
t.assert.strictEqual(composedSignalRef.deref(), undefined);
147-
t.assert.strictEqual(controllers[0].signal[kDependantSignals].size, 2);
148-
t.assert.strictEqual(controllers[1].signal[kDependantSignals].size, 1);
149-
150-
setImmediate(() => {
151-
t.assert.strictEqual(controllers[0].signal[kDependantSignals].size, 0);
152-
t.assert.strictEqual(controllers[1].signal[kDependantSignals].size, 0);
146+
t.assert.strictEqual(controllers[0].signal[kDependantSignals].size, 2);
147+
t.assert.strictEqual(controllers[1].signal[kDependantSignals].size, 1);
153148

154-
done();
149+
setImmediate(() => {
150+
global.gc({ execution: 'async' }).then(async () => {
151+
await gcUntil('all signals are GCed', () => {
152+
const totalDependantSignals = Math.max(
153+
controllers[0].signal[kDependantSignals].size,
154+
controllers[1].signal[kDependantSignals].size
155+
);
156+
157+
return composedSignalRef.deref() === undefined && totalDependantSignals === 0;
155158
});
159+
160+
done();
156161
});
157162
});
158163
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.