main
1// Builds the Worker with `cf build` and copies the bundle that `cf deploy --prebuilt` would upload, so the workerd
2// suites run the deployed artifact rather than a test-only bundle.
3import { spawnSync } from 'node:child_process';
4import { copyFileSync, existsSync, readdirSync, readFileSync } from 'node:fs';
5import { join } from 'node:path';
6import { fileURLToPath } from 'node:url';
8const ROOT = fileURLToPath(new URL('..', import.meta.url));
9const CF = join(ROOT, 'node_modules', '.bin', 'cf');
10// cf's Build Output Specification, version 0. One Worker, named "default" because it is the only one.
11const WORKER_OUTPUT = join(ROOT, '.cloudflare', 'output', 'v0', 'workers', 'default');
13// `npm test` builds once (`node test/cf-bundle.js`) and sets PLY_WEB_BUNDLE_BUILT=1 for the suites, which node --test runs
14// in separate processes. Without it each of the three workerd suites ran its own `cf build` (2.5 s CPU, 33-39 s wall on a loaded
15// machine, 2026-10-31). A suite run on its own still builds.
16const PREBUILT = process.env.PLY_WEB_BUNDLE_BUILT === '1';
18/** Runs `cf build` once per process (or once per `npm test`) and returns the absolute path of the bundled main module. */
19let built;
20export function cfBundle() {
21 built ??= (() => {
22 if (!PREBUILT) {
23 if (!existsSync(CF)) throw new Error(`cf is not installed at ${CF}. Run npm ci.`);
24 const run = spawnSync(CF, ['build', '--quiet'], { cwd: ROOT, encoding: 'utf8', env: { ...process.env, CF_SEND_TELEMETRY: 'false' } });
25 if (run.status !== 0) throw new Error(`cf build exited ${run.status}\n${run.stdout}\n${run.stderr}`);
26 }
27 const { manifest } = JSON.parse(readFileSync(join(WORKER_OUTPUT, 'worker.config.json'), 'utf8'));
28 const bundleDir = join(WORKER_OUTPUT, 'bundle');
29 const modules = readdirSync(bundleDir).filter(name => name.endsWith('.js'));
30 // workerd configs here embed a single module. A split bundle needs every chunk listed; fail loudly instead.
31 if (modules.length !== 1 || modules[0] !== manifest.mainModule) {
32 throw new Error(`expected one module, ${manifest.mainModule}, in ${bundleDir}; found ${modules.join(', ')}`);
33 }
34 return join(bundleDir, manifest.mainModule);
35 })();
36 return built;
37}
39/** Copies the cf-built bundle to `dest`, the path the workerd config embeds. */
40export function copyCfBundle(dest) {
41 copyFileSync(cfBundle(), dest);
42}
44// `node test/cf-bundle.js` builds and checks the bundle once, before the suites.
45if (process.argv[1] === fileURLToPath(import.meta.url)) cfBundle();
Diagnostics4 git calls · 25 ms
CallStatusSizeTime025 ms
discover200152 B4 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=4 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200145 B · hit4 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=4 git.response.bytes=145 git.response.cache=HIT git.response.duration_ms=4 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=145 git.pkt.payload.max=76 git.ls_refs.count=2 git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020040 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=41349 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=526b305930b8ef382f2d7a1f9c0238730a585921 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=6 git.pkt.data=4 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=41349 git.pkt.payload.max=41254 git.sideband.band1.bytes=41253 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=61 git.pack.bytes=41253 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c git.pack.full=61Open pack map
fetch2001.3 KiB · hit18 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=18 git.response.bytes=1288 git.response.cache=HIT git.response.duration_ms=18 git.fetch.wants=464c569c289cf0257e1c10879fd0bb65bf339b0d git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1288 git.pkt.payload.max=1267 git.sideband.band1.bytes=1266 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply-web.git
- Ref
- refs/heads/main
- Commit
- 526b305930b8ef382f2d7a1f9c0238730a585921
- cf-ray
- a5e2553b2e411ae0
- Request
- 93b76ec3…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format