diff --git a/workbench/nextjs-turbopack/app/api/e2e-h2-flag/route.ts b/workbench/nextjs-turbopack/app/api/e2e-h2-flag/route.ts new file mode 100644 index 0000000000..56eb345278 --- /dev/null +++ b/workbench/nextjs-turbopack/app/api/e2e-h2-flag/route.ts @@ -0,0 +1,21 @@ +/** + * Repro-branch probe. Proves that `WORKFLOW_H2_MULTIPLEX`, set in this app's + * `vercel.json` `env` block, actually reaches the deployed function's *runtime* + * environment — which is where `@workflow/world-vercel` reads it, lazily, in + * `createEventsDispatcher()` (packages/world-vercel/src/http-client.ts). + * + * Without this probe a flag-off storm that measures no change is ambiguous + * between "multiplexing is not the cause" and "the flag never arrived". + */ +export const dynamic = 'force-dynamic'; + +export function GET() { + return Response.json({ + WORKFLOW_H2_MULTIPLEX: process.env.WORKFLOW_H2_MULTIPLEX ?? null, + // Mirrors `h2MultiplexEnabled()` in world-vercel's http-client. + multiplexEnabled: process.env.WORKFLOW_H2_MULTIPLEX !== '0', + // 'vercel.json' if the deployment supplied it, 'instrumentation' if the + // fallback in instrumentation.ts had to. + source: process.env.WORKFLOW_H2_MULTIPLEX_SOURCE ?? null, + }); +} diff --git a/workbench/nextjs-turbopack/instrumentation.ts b/workbench/nextjs-turbopack/instrumentation.ts index bd66985a97..ed7d636e0f 100644 --- a/workbench/nextjs-turbopack/instrumentation.ts +++ b/workbench/nextjs-turbopack/instrumentation.ts @@ -1,5 +1,21 @@ import { registerOTel } from '@vercel/otel'; +// Repro branch only. `vercel.json`'s `env` block is the documented way to give +// the deployed functions a runtime variable, but Vercel marks it deprecated, so +// this is the belt to that suspenders: if the block were ignored, a storm here +// would measure stock main and read as "multiplexing is not the cause". +// `@workflow/world-vercel` reads the variable lazily in +// `createEventsDispatcher()`, which always runs after instrumentation, so +// setting it here reaches the same code path. +// Recorded so the probe route can also tell us whether the deprecated +// `vercel.json` block still works — that decides where the real mitigation +// advice should point if #3190 turns out to own the regression. +process.env.WORKFLOW_H2_MULTIPLEX_SOURCE = + process.env.WORKFLOW_H2_MULTIPLEX === undefined + ? 'instrumentation' + : 'vercel.json'; +process.env.WORKFLOW_H2_MULTIPLEX ??= '0'; + export function register() { registerOTel({ serviceName: 'nextjs-turbopack', diff --git a/workbench/nextjs-turbopack/vercel.json b/workbench/nextjs-turbopack/vercel.json index aa4f892410..cc7e0a3f9f 100644 --- a/workbench/nextjs-turbopack/vercel.json +++ b/workbench/nextjs-turbopack/vercel.json @@ -1,6 +1,7 @@ { "env": { - "WORKFLOW_PUBLIC_MANIFEST": "1" + "WORKFLOW_PUBLIC_MANIFEST": "1", + "WORKFLOW_H2_MULTIPLEX": "0" }, "regions": [ "iad1",