From 1c6c1ae1945f5a3cd920d637f16c248c52409360 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 28 Jul 2026 08:12:01 -0700 Subject: [PATCH] test(nextjs): ensure orchestrion stays out of client bundles We are already restricting orchestrion channel injections to only be active in the server bundle, but this test ensures that never slips. Webpack, Vite, and Nuxt are already covered by tests, so Turbopack was the last remaining gap. --- .../turbopack/constructTurbopackConfig.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts b/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts index 25bc45d3ac4c..fadb4cdd4820 100644 --- a/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts +++ b/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts @@ -1337,6 +1337,19 @@ describe('orchestrion diagnostics-channel injection', () => { expect(JSON.parse(JSON.stringify(firestore!.module.filePath))).not.toEqual({}); }); + it('restricts the orchestrion rule to the node environment', () => { + const result = constructTurbopackConfig({ + userNextConfig: {}, + userSentryOptions: { _experimental: { useDiagnosticsChannelInjection: true } }, + nextJsVersion: '16.0.0', + }); + + // `condition: 'node'` is what keeps the transform off client code — orchestrion + // splices `node:diagnostics_channel` calls that throw `X is not a function` in the browser. + const rule = result.rules!['*.{js,mjs,cjs}'] as { condition?: unknown }; + expect(rule.condition).toBe('node'); + }); + it('does not add the orchestrion rule when injection is not opted in', () => { const result = constructTurbopackConfig({ userNextConfig: {},