Skip to content

Commit 2bee0b4

Browse files
committed
test(remix): Test Remix SDK on Node 20.
1 parent f669f66 commit 2bee0b4

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ jobs:
706706
strategy:
707707
fail-fast: false
708708
matrix:
709-
node: [14, 16, 18]
709+
node: [14, 16, 18, 20]
710710
remix: [1, 2]
711711
steps:
712712
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})

packages/node-integration-tests/utils/index.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import type { AddressInfo } from 'net';
1010
import nock from 'nock';
1111
import * as path from 'path';
1212

13+
const NODE_VERSION = parseSemver(process.versions.node).major;
14+
1315
export type TestServerConfig = {
1416
url: string;
1517
server: http.Server;
@@ -40,7 +42,6 @@ export type DataCollectorOptions = {
4042
* @return {*} {jest.Describe}
4143
*/
4244
export const conditionalTest = (allowedVersion: { min?: number; max?: number }): jest.Describe => {
43-
const NODE_VERSION = parseSemver(process.versions.node).major;
4445
if (!NODE_VERSION) {
4546
return describe.skip;
4647
}
@@ -127,6 +128,16 @@ export class TestEnv {
127128
public constructor(public readonly server: http.Server, public readonly url: string) {
128129
this.server = server;
129130
this.url = url;
131+
132+
// We need to destroy the socket after the response has been sent
133+
// to prevent the server.close (called inside nock interceptor) from hanging in tests.
134+
// Otherwise the tests may timeout. (Happening on Node 20)
135+
// See: https://github.com/nodejs/node/issues/2642
136+
this.server.on('request', (req, res) => {
137+
res.on('finish', () => {
138+
req.socket.end();
139+
});
140+
});
130141
}
131142

132143
/**
@@ -244,9 +255,7 @@ export class TestEnv {
244255
// Ex: Remix scope bleed tests.
245256
nock.cleanAll();
246257

247-
this.server.close(() => {
248-
resolve(envelopes);
249-
});
258+
this._closeServer();
250259
}
251260

252261
resolve(envelopes);
@@ -291,12 +300,19 @@ export class TestEnv {
291300

292301
nock.cleanAll();
293302

294-
this.server.close(() => {
295-
resolve(reqCount);
296-
});
297-
303+
this._closeServer();
298304
resolve(reqCount);
299305
}, options.timeout || 1000);
300306
});
301307
}
308+
309+
private _closeServer(): void {
310+
this.server.close(() => {
311+
// @ts-ignore closeAllConnections() is only available from Node v18.2.0
312+
if (NODE_VERSION >= 18 && this.server.closeAllConnections) {
313+
// @ts-ignore (Only available in Node 18+)
314+
this.server.closeAllConnections();
315+
}
316+
});
317+
}
302318
}

0 commit comments

Comments
 (0)