Skip to content
Open
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
15 changes: 3 additions & 12 deletions test/parallel/test-fs-promises-file-handle-writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,8 @@ async function testWriteWithAbortedSignalRejects() {
const fh = await open(filePath, 'w');
const w = fh.writer();

const ac = new AbortController();
ac.abort();

await assert.rejects(
w.write(Buffer.from('data'), { signal: ac.signal }),
w.write(Buffer.from('data'), { signal: AbortSignal.abort() }),
{ name: 'AbortError' },
);

Expand All @@ -479,11 +476,8 @@ async function testWritevWithAbortedSignalRejects() {
const fh = await open(filePath, 'w');
const w = fh.writer();

const ac = new AbortController();
ac.abort();

await assert.rejects(
w.writev([Buffer.from('a'), Buffer.from('b')], { signal: ac.signal }),
w.writev([Buffer.from('a'), Buffer.from('b')], { signal: AbortSignal.abort() }),
{ name: 'AbortError' },
);

Expand All @@ -501,11 +495,8 @@ async function testEndWithAbortedSignalRejects() {

await w.write(Buffer.from('data'));

const ac = new AbortController();
ac.abort();

await assert.rejects(
w.end({ signal: ac.signal }),
w.end({ signal: AbortSignal.abort() }),
{ name: 'AbortError' },
);

Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-runner-mock-timers-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ describe('Mock Timers Scheduler Test Suite', () => {

it('should abort operation when .abort is called before calling setInterval', async (t) => {
t.mock.timers.enable({ apis: ['scheduler.wait'] });
const controller = new AbortController();
controller.abort();
const p = nodeTimersPromises.scheduler.wait(2000, {
ref: true,
signal: controller.signal,
signal: AbortSignal.abort(),
});

await assert.rejects(() => p, {
Expand Down
8 changes: 2 additions & 6 deletions test/parallel/test-runner-mock-timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,9 @@ describe('Mock Timers Test Suite', () => {
it('should abort operation when .abort is called before calling setInterval', async (t) => {
t.mock.timers.enable({ apis: ['setTimeout'] });
const expectedResult = 'result';
const controller = new AbortController();
controller.abort();
const p = nodeTimersPromises.setTimeout(2000, expectedResult, {
ref: true,
signal: controller.signal,
signal: AbortSignal.abort(),
});

await assert.rejects(() => p, {
Expand Down Expand Up @@ -778,10 +776,8 @@ describe('Mock Timers Test Suite', () => {
t.mock.timers.enable({ apis: ['setInterval'] });

const interval = 100;
const abortController = new AbortController();
abortController.abort();
const intervalIterator = nodeTimersPromises.setInterval(interval, Date.now(), {
signal: abortController.signal,
signal: AbortSignal.abort(),
});

const first = intervalIterator.next();
Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-stream-iter-broadcast-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ async function testAbortSignal() {
}

async function testAlreadyAbortedSignal() {
const ac = new AbortController();
ac.abort();

const { broadcast: bc } = broadcast({ signal: ac.signal });
const { broadcast: bc } = broadcast({ signal: AbortSignal.abort() });
const consumer = bc.push();

const batches = [];
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-stream-iter-consumers-bytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ async function testBytesAsyncLimit() {
}

async function testBytesAsyncAbort() {
const ac = new AbortController();
ac.abort();
await assert.rejects(
() => bytes(from('data'), { signal: ac.signal }),
() => bytes(from('data'), { signal: AbortSignal.abort() }),
{ name: 'AbortError' },
);
}
Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-stream-iter-consumers-merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ async function testMergeEmpty() {
}

async function testMergeWithAbortSignal() {
const ac = new AbortController();
ac.abort();

const merged = merge(from('data'), { signal: ac.signal });
const merged = merge(from('data'), { signal: AbortSignal.abort() });

await assert.rejects(
async () => {
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-stream-iter-consumers-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ async function testTextEmpty() {

// text() with abort signal
async function testTextWithSignal() {
const ac = new AbortController();
ac.abort();
await assert.rejects(
() => text(from('data'), { signal: ac.signal }),
() => text(from('data'), { signal: AbortSignal.abort() }),
{ name: 'AbortError' },
);
}
Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-stream-iter-pull-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ async function testPullStatefulTransform() {
}

async function testPullWithAbortSignal() {
const ac = new AbortController();
ac.abort();

async function* gen() {
yield [new Uint8Array([1])];
}

const result = pull(gen(), { signal: ac.signal });
const result = pull(gen(), { signal: AbortSignal.abort() });
await assert.rejects(
async () => {
// eslint-disable-next-line no-unused-vars
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-stream-iter-push-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ async function testAbortSignal() {
}

async function testPreAbortedSignal() {
const ac = new AbortController();
ac.abort();
const { readable } = push({ signal: ac.signal });
const { readable } = push({ signal: AbortSignal.abort() });
await assert.rejects(async () => {
// eslint-disable-next-line no-unused-vars
for await (const _ of readable) {
Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-stream-iter-push-writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ async function testWriteWithSignalRejects() {
async function testWriteWithPreAbortedSignal() {
const { writer, readable } = push({ highWaterMark: 1 });

const ac = new AbortController();
ac.abort();

// Pre-aborted signal should reject immediately
await assert.rejects(
writer.write('data', { signal: ac.signal }),
writer.write('data', { signal: AbortSignal.abort() }),
{ name: 'AbortError' },
);

Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-stream-iter-share-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ async function testShareAbortSignal() {
}

async function testShareAlreadyAborted() {
const ac = new AbortController();
ac.abort();

const shared = share(from('data'), { signal: ac.signal });
const shared = share(from('data'), { signal: AbortSignal.abort() });
const consumer = shared.pull();

const batches = [];
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-stream-iter-to-readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ async function testSignalAlreadyAborted() {
yield [Buffer.from('should not reach')];
}

const ac = new AbortController();
ac.abort();
const readable = toReadable(gen(), { signal: ac.signal });
const readable = toReadable(gen(), { signal: AbortSignal.abort() });

await assert.rejects(async () => {
// eslint-disable-next-line no-unused-vars
Expand Down
Loading