+17
-12
lines changedFilter options
+17
-12
lines changed Original file line number Diff line number Diff line change
@@ -134,25 +134,30 @@ it('does not prevent source signal from being GCed if it is short-lived', (t, do
134
134
135
135
it('drops settled dependant signals when signal is composite', (t, done) => {
136
136
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]));
139
141
140
142
const kDependantSignals = Object.getOwnPropertySymbols(controllers[0].signal).find(
141
143
(s) => s.toString() === 'Symbol(kDependantSignals)'
142
144
);
143
145
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);
153
148
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;
155
158
});
159
+
160
+
done();
156
161
});
157
162
});
158
163
});
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4