| 1 | import assert from "node:assert/strict"; |
| 2 | import { join } from "node:path"; |
| 3 | // oxlint-disable-next-line import/no-unassigned-import |
| 4 | import "node:perf_hooks"; |
| 5 | import { stderr } from "./early-process-access"; |
| 6 | |
| 7 | export default { |
| 8 | async fetch() { |
| 9 | assert(stderr, "process.stderr was not polyfilled early enough"); |
| 10 | assert(join("a", "b") === "a/b", "expected posix path joining"); |
| 11 | |
| 12 | const buffer1 = Buffer.of(1); |
| 13 | assert(buffer1.toJSON().data[0] === 1, "Buffer is broken"); |
| 14 | |
| 15 | const buffer2 = global.Buffer.of(1); |
| 16 | assert(buffer2.toJSON().data[0] === 1, "global.Buffer is broken"); |
| 17 | |
| 18 | const buffer3 = globalThis.Buffer.of(1); |
| 19 | assert(buffer3.toJSON().data[0] === 1, "globalThis.Buffer is broken"); |
| 20 | |
| 21 | assert(performance !== undefined, "performance is missing"); |
| 22 | assert(global.performance !== undefined, "global.performance is missing"); |
| 23 | assert( |
| 24 | globalThis.performance !== undefined, |
| 25 | "globalThis.performance is missing", |
| 26 | ); |
| 27 | |
| 28 | assert(process !== undefined, "process is missing"); |
| 29 | assert(global.process === process, "global.process is not synced"); |
| 30 | assert(globalThis.process === process, "globalThis.process is not synced"); |
| 31 | |
| 32 | return new Response("OK!"); |
| 33 | }, |
| 34 | } satisfies ExportedHandler; |