diff --git a/test/e2e/instrumentation-hook/register-once/instrumentation.js b/test/e2e/instrumentation-hook/register-once/instrumentation.js index f96e7a7d10a96..276640bdd6071 100644 --- a/test/e2e/instrumentation-hook/register-once/instrumentation.js +++ b/test/e2e/instrumentation-hook/register-once/instrumentation.js @@ -1,5 +1,11 @@ +let count = 0 + export function register() { if (process.env.NEXT_RUNTIME === 'nodejs') { + if (count > 0) { + throw new Error('duplicated-register') + } console.log('register-log') + count++ } } diff --git a/test/e2e/instrumentation-hook/register-once/register-once.test.ts b/test/e2e/instrumentation-hook/register-once/register-once.test.ts index 88bbb39ac7bb2..da8459f0413a4 100644 --- a/test/e2e/instrumentation-hook/register-once/register-once.test.ts +++ b/test/e2e/instrumentation-hook/register-once/register-once.test.ts @@ -1,17 +1,18 @@ import { nextTestSetup } from 'e2e-utils' describe('instrumentation-hook - register-once', () => { - const { next, skipped } = nextTestSetup({ + const { next } = nextTestSetup({ files: __dirname, - skipDeployment: true, }) - if (skipped) { - return - } - it('should only register once', async () => { await next.fetch('/foo') expect(next.cliOutput).toIncludeRepeated('register-log', 1) }) + + it('should not error when concurrent requests are made', async () => { + await Promise.all([next.fetch('/foo'), next.fetch('/foo')]) + expect(next.cliOutput).toIncludeRepeated('register-log', 1) + expect(next.cliOutput).not.toInclude('duplicated-register') + }) })