From af8f8bdeb969c58cf30ff3cb39e026ab43439acd Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Tue, 18 Jul 2023 12:17:18 +0100 Subject: [PATCH] test(remix): Test Remix SDK on Node 20. --- .github/workflows/build.yml | 2 +- packages/node-integration-tests/utils/index.ts | 14 +++++++++++--- .../test/integration/test/server/action.test.ts | 1 + .../test/integration/test/server/loader.test.ts | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5523a861eee..0c024683bd4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -706,7 +706,7 @@ jobs: strategy: fail-fast: false matrix: - node: [14, 16, 18] + node: [14, 16, 18, 20] remix: [1, 2] steps: - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) diff --git a/packages/node-integration-tests/utils/index.ts b/packages/node-integration-tests/utils/index.ts index 88120853ee69..4da3c70246b5 100644 --- a/packages/node-integration-tests/utils/index.ts +++ b/packages/node-integration-tests/utils/index.ts @@ -127,6 +127,16 @@ export class TestEnv { public constructor(public readonly server: http.Server, public readonly url: string) { this.server = server; this.url = url; + + // We need to destroy the socket after the response has been sent + // to prevent the server.close (called inside nock interceptor) from hanging in tests. + // Otherwise the tests may timeout. (Happening on Node 20) + // See: https://github.com/nodejs/node/issues/2642 + this.server.on('request', (req, res) => { + res.on('finish', () => { + req.socket.end(); + }); + }); } /** @@ -244,9 +254,7 @@ export class TestEnv { // Ex: Remix scope bleed tests. nock.cleanAll(); - this.server.close(() => { - resolve(envelopes); - }); + this.server.close(); } resolve(envelopes); diff --git a/packages/remix/test/integration/test/server/action.test.ts b/packages/remix/test/integration/test/server/action.test.ts index a2a4632ba962..c6a595177b0a 100644 --- a/packages/remix/test/integration/test/server/action.test.ts +++ b/packages/remix/test/integration/test/server/action.test.ts @@ -3,6 +3,7 @@ import { assertSentryTransaction, assertSentryEvent, RemixTestEnv } from './util const useV2 = process.env.REMIX_VERSION === '2'; jest.spyOn(console, 'error').mockImplementation(); +jest.setTimeout(10000); // Repeat tests for each adapter describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', adapter => { diff --git a/packages/remix/test/integration/test/server/loader.test.ts b/packages/remix/test/integration/test/server/loader.test.ts index ccaa93b05e36..2ca5fd385b42 100644 --- a/packages/remix/test/integration/test/server/loader.test.ts +++ b/packages/remix/test/integration/test/server/loader.test.ts @@ -4,6 +4,7 @@ import { Event } from '@sentry/types'; const useV2 = process.env.REMIX_VERSION === '2'; jest.spyOn(console, 'error').mockImplementation(); +jest.setTimeout(10000); // Repeat tests for each adapter describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', adapter => {