Skip to content

Commit 3ca7b38

Browse files
committed
Run CI tests on Node 23
1 parent e3572d0 commit 3ca7b38

File tree

6 files changed

+37
-19
lines changed

6 files changed

+37
-19
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 22
13+
- 23
1414
- 18
1515
os:
1616
- ubuntu
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
args: --cache --verbose --no-progress --include-fragments --exclude packagephobia --exclude /pull/ --exclude linkedin --exclude file:///test --exclude invalid.com '*.md' 'docs/*.md' '.github/**/*.md' '*.json' '*.js' 'lib/**/*.js' 'test/**/*.js' '*.ts' 'test-d/**/*.ts'
3333
fail: true
34-
if: ${{ matrix.os == 'ubuntu' && matrix.node-version == 22 }}
34+
if: ${{ matrix.os == 'ubuntu' && matrix.node-version == 23 }}
3535
- run: npm run lint
3636
- run: npm run type
3737
- run: npm run unit

test/convert/duplex.js

+16-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
getReadWriteSubprocess,
2424
} from '../helpers/convert.js';
2525
import {foobarString} from '../helpers/input.js';
26+
import {majorNodeVersion} from '../helpers/node-version.js';
2627
import {prematureClose, fullStdio, fullReadableStdio} from '../helpers/stdio.js';
2728
import {defaultHighWaterMark} from '../helpers/stream.js';
2829

@@ -148,13 +149,21 @@ test('.duplex() can pipe to errored stream with Stream.pipeline()', async t => {
148149
const cause = new Error('test');
149150
outputStream.destroy(cause);
150151

151-
await assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);
152-
await t.throwsAsync(finishedStream(stream));
153-
154-
await assertStreamError(t, inputStream, cause);
155-
const error = await assertStreamError(t, stream, cause);
156-
await assertStreamReadError(t, outputStream, cause);
157-
await assertSubprocessError(t, subprocess, {cause: error});
152+
// Node 23 does not allow calling `stream.pipeline()` with an already errored stream
153+
if (majorNodeVersion >= 23) {
154+
outputStream.on('error', () => {});
155+
stream.on('error', () => {});
156+
await t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});
157+
stream.end();
158+
} else {
159+
await assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);
160+
await t.throwsAsync(finishedStream(stream));
161+
162+
await assertStreamError(t, inputStream, cause);
163+
const error = await assertStreamError(t, stream, cause);
164+
await assertStreamReadError(t, outputStream, cause);
165+
await assertSubprocessError(t, subprocess, {cause: error});
166+
}
158167
});
159168

160169
test('.duplex() can be piped to errored stream with Stream.pipeline()', async t => {

test/convert/readable.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
} from '../helpers/convert.js';
3030
import {foobarString, foobarBuffer, foobarObject} from '../helpers/input.js';
3131
import {simpleFull} from '../helpers/lines.js';
32+
import {majorNodeVersion} from '../helpers/node-version.js';
3233
import {prematureClose, fullStdio} from '../helpers/stdio.js';
3334
import {outputObjectGenerator, getOutputsAsyncGenerator} from '../helpers/generator.js';
3435
import {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';
@@ -231,12 +232,18 @@ test('.readable() can pipe to errored stream with Stream.pipeline()', async t =>
231232
const cause = new Error('test');
232233
outputStream.destroy(cause);
233234

234-
await assertPromiseError(t, pipeline(stream, outputStream), cause);
235-
await t.throwsAsync(finishedStream(stream));
236-
237-
const error = await assertStreamError(t, stream, cause);
238-
await assertStreamReadError(t, outputStream, cause);
239-
await assertSubprocessError(t, subprocess, {cause: error});
235+
// Node 23 does not allow calling `stream.pipeline()` with an already errored stream
236+
if (majorNodeVersion >= 23) {
237+
outputStream.on('error', () => {});
238+
await t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});
239+
} else {
240+
await assertPromiseError(t, pipeline(stream, outputStream), cause);
241+
await t.throwsAsync(finishedStream(stream));
242+
243+
const error = await assertStreamError(t, stream, cause);
244+
await assertStreamReadError(t, outputStream, cause);
245+
await assertSubprocessError(t, subprocess, {cause: error});
246+
}
240247
});
241248

242249
test('.readable() can be used with Stream.compose()', async t => {

test/fixtures/graceful-ref.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env node
2-
import {once} from 'node:events';
32
import {getCancelSignal} from 'execa';
43

54
const cancelSignal = await getCancelSignal();
6-
once(cancelSignal, 'abort');
5+
cancelSignal.addEventListener('abort', () => {});

test/helpers/node-version.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import {version} from 'node:process';
2+
3+
export const majorNodeVersion = Number(version.split('.')[0].slice(1));

test/terminate/kill-signal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import {once} from 'node:events';
2-
import {platform, version} from 'node:process';
2+
import {platform} from 'node:process';
33
import {constants} from 'node:os';
44
import {setImmediate} from 'node:timers/promises';
55
import test from 'ava';
66
import {execa, execaSync} from '../../index.js';
77
import {setFixtureDirectory} from '../helpers/fixtures-directory.js';
8+
import {majorNodeVersion} from '../helpers/node-version.js';
89

910
setFixtureDirectory();
1011

1112
const isWindows = platform === 'win32';
12-
const majorNodeVersion = Number(version.split('.')[0].slice(1));
1313

1414
const testKillSignal = async (t, killSignal) => {
1515
const {isTerminated, signal} = await t.throwsAsync(execa('forever.js', {killSignal, timeout: 1}));

0 commit comments

Comments
 (0)