diff --git a/packages/functions-compiler/src/shim/entry.ts b/packages/functions-compiler/src/shim/entry.ts index b642a2ef..25ff92dc 100644 --- a/packages/functions-compiler/src/shim/entry.ts +++ b/packages/functions-compiler/src/shim/entry.ts @@ -67,6 +67,8 @@ const deno = Object.freeze({ (globalThis as unknown as { Deno: unknown }).Deno = deno; (globalThis as unknown as { Buffer: typeof Buffer }).Buffer = Buffer; +// workerd reports a fixed v22.19.0, which SDKs forward (Stripe in its user agent). +if (typeof process !== "undefined") (process as { version: string }).version = "v22.23.4"; // workerd's enterWith() is a stub that throws; libraries such as Stagehand // call it to seed a context they also pass explicitly, so a no-op keeps them // working. Probed on a throwaway instance so a future native implementation is diff --git a/packages/functions-compiler/test/process-version.e2e.test.ts b/packages/functions-compiler/test/process-version.e2e.test.ts new file mode 100644 index 00000000..4d380e1e --- /dev/null +++ b/packages/functions-compiler/test/process-version.e2e.test.ts @@ -0,0 +1,14 @@ +import { expect, it } from "vitest"; + +import { bundleOrThrow } from "./helpers"; +import { runInWorkerd } from "./workerd"; + +it("reports the patched Node version to user code", async () => { + const m = await bundleOrThrow(` + const atImport = process.version; + Deno.serve(() => Response.json({ atImport, atRequest: process.version })); + `); + const { status, text } = await runInWorkerd(m); + expect(status).toBe(200); + expect(JSON.parse(text)).toEqual({ atImport: "v22.23.4", atRequest: "v22.23.4" }); +});