Artifactspublic-v0

ply

main
ply4 git calls241 ms45 KiB2 cachedprotocol v2
301 lines23 KiBRaw
1// The pipeline under workerd (the Workers runtime ply's main consumer runs on), against the local git server. The worker
2// is test/workerd/worker.mjs bundled with src by esbuild (test/workerd/build.mjs). Part of the default suite and CI.
3// workerd is a devDependency; without it the tests skip locally, and fail under CI (a skipped suite is a dead suite, #101).
4// WORKERD=/path/to/workerd npx vitest run test/workerd.test.js (default: looks in ./node_modules/.bin and ../wd/node_modules/.bin)
5import { test, beforeAll as before, afterAll as after } from 'vitest';
6import assert from 'node:assert/strict';
7import { spawn } from 'node:child_process';
8import { randomBytes } from 'node:crypto';
9import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
10import http from 'node:http';
11import { join } from 'node:path';
12import { fileURLToPath } from 'node:url';
13import { git, gitBuf, gitUserinfoCred, gitWithCred, tmpRoot, makeBareRepo, startGitServer, startAuthGate, commitFiles, fsckProblems, initRepo } from './server.js';
14import { build } from './workerd/build.mjs';
16const candidates = [process.env.WORKERD, fileURLToPath(new URL('../node_modules/.bin/workerd', import.meta.url)), fileURLToPath(new URL('../../wd/node_modules/.bin/workerd', import.meta.url))].filter(Boolean);
17const WORKERD = candidates.find(p => existsSync(p));
18const PORT = 18790 + (process.pid % 100);
19if (!WORKERD && process.env.CI) throw new Error(`workerd not found (looked in ${candidates.join(', ')}); CI must run this suite`);
21let root, cleanup, srv, proc;
22before(async () => {
23 if (!WORKERD) return;
24 ({ root, cleanup } = tmpRoot());
25 srv = await startGitServer(root);
26 const cfg = build({ port: PORT, outDir: join(root, 'wd') });
27 proc = spawn(WORKERD, ['serve', cfg], { stdio: ['ignore', 'pipe', 'pipe'] });
28 let stderr = '';
29 proc.stderr.on('data', d => { stderr = (stderr + d).slice(-4000); if (/error/i.test(String(d))) console.error('workerd:', String(d).slice(0, 300)); });
30 for (let i = 0; i < 100; i++) { try { if ((await fetch(`http://127.0.0.1:${PORT}/ping`)).ok) return; } catch { } await new Promise(r => setTimeout(r, 100)); }
31 throw new Error(`workerd did not answer /ping on ${PORT} within 10 s (exit ${proc.exitCode}):\n${stderr}`);
32});
33after(async () => { if (!WORKERD) return; proc?.kill(); await srv?.close(); cleanup?.(); });
35const post = async (path, body, q = '') => (await fetch(`http://127.0.0.1:${PORT}${path}${q}`, { method: 'POST', body: JSON.stringify(body) })).json();
37// packSubset awaits a chunk read bare on the platform's reader and relies on the halt's reader.cancel() to settle a read
38// in flight. The Streams standard says it does, with done (ReadableStreamCancel closes the stream, and closing resolves
39// every pending read request). workerd settles it too on an internal stream, here a fetch body whose server stalls
40// after 1024 bytes (an R2 body is the same kind of stream), but by rejecting it (seen at compatibilityDate 2024-09-23).
41// What packSubset needs is that it settles, either way; the second test is packSubset itself over that stream.
42// Turns are counted, not timed.
43test('workerd: cancel() settles a read in flight on an internal stream', { skip: !WORKERD }, async () => {
44 const server = http.createServer((req, res) => { res.writeHead(200, { 'content-type': 'application/octet-stream' }); res.write(Buffer.alloc(1024, 7)); /* never ends */ });
45 await new Promise(r => server.listen(0, '127.0.0.1', r));
46 try {
47 const r = await post('/cancel-pending-read', { url: `http://127.0.0.1:${server.address().port}/stall`, bytes: 1024 });
48 assert.deepEqual([r.got, r.before], [1024, 'pending'], JSON.stringify(r));
49 assert.ok(r.after === 'done' || r.after === 'rejected', `the read in flight settles: ${JSON.stringify(r)}`);
50 } finally { server.closeAllConnections(); server.close(); }
51});
52// 1036 = the 12-byte pack header + the 1024 bytes the server sends before it stalls (the entry's header is skipped
53// from the range and written anew, the same length). Then: the consumer's read in flight ends (done: the stream is
54// cancelled) and cancel() settles. Not asserted, and open: workerd reports one unhandled rejection carrying the cancel
55// reason (`rejections` here, `unhandled` in the route above, which runs no ply code and handles both of its promises:
56// it is the platform reader's own), the same with the chunk read raced as with it awaited bare.
57test('workerd: packSubset over an internal stream that stalls: cancel settles and the read in flight ends', { skip: !WORKERD }, async () => {
58 const server = http.createServer((req, res) => { res.writeHead(200, { 'content-type': 'application/octet-stream' }); res.write(Buffer.alloc(1024, 7)); /* never ends */ });
59 await new Promise(r => server.listen(0, '127.0.0.1', r));
60 try {
61 const r = await post('/subset-cancel', { url: `http://127.0.0.1:${server.address().port}/stall`, bytes: 1036 });
62 assert.deepEqual([r.got, r.before, r.read, r.cancel], [1036, 'pending', 'done', 'settled'], JSON.stringify(r));
63 } finally { server.closeAllConnections(); server.close(); }
64});
66// #255 under workerd: a Node server that drips, stalls or answers late; the worker's transport must cut stalls (first
67// byte, idle) and let a long steady exchange through. Timers in workerd fire while a body read is pending.
68test('workerd: first-byte and idle timeouts; a long steady body or upload is not cut', { skip: !WORKERD }, async () => {
69 const sleep = ms => new Promise(r => setTimeout(r, ms));
70 const server = http.createServer(async (req, res) => {
71 const mode = new URL(req.url, 'http://x').pathname.split('/')[1];
72 // a client that gives up resets the connection mid-upload: that is the expected end of those cases
73 try { for await (const _ of req) { /* the upload, read as it comes */ } } catch { return; }
74 if (mode === 'slowheaders') await sleep(800);
75 res.writeHead(200, { 'content-type': 'application/x-git-upload-pack-result' });
76 const frames = mode === 'steady' ? 20 : mode === 'stall' ? 2 : 1;
77 for (let i = 0; i < frames; i++) { res.write('0008abcd'); if (mode === 'steady') await sleep(40); }
78 if (mode === 'stall') return; // never ends: the client must give up
79 res.end('0000');
80 });
81 await new Promise(r => server.listen(0, '127.0.0.1', r));
82 const base = `http://127.0.0.1:${server.address().port}`;
83 const limits = { firstByteTimeoutMs: 250, idleTimeoutMs: 250 };
84 try {
85 const run = (mode, extra = {}) => post('/timeouts', { url: `${base}/${mode}/r.git`, mode, limits: { ...limits, ...extra } });
86 const steady = await run('steady');
87 assert.deepEqual([steady.ok, steady.frames], [true, 21], JSON.stringify(steady));
88 assert.ok(steady.ms > 600, `steady body ran ${steady.ms} ms, past every 250 ms timer`);
89 const capped = await run('steady', { requestTimeoutMs: 400 });
90 assert.deepEqual([capped.ok, capped.code, capped.what], [false, 'timeout', 'requestTimeoutMs'], JSON.stringify(capped));
91 const stall = await run('stall');
92 assert.deepEqual([stall.ok, stall.code, stall.what, stall.limit], [false, 'timeout', 'idleTimeoutMs', 'idleTimeoutMs'], JSON.stringify(stall));
93 assert.ok(stall.ms < 3000, `${stall.ms} ms`);
94 const slow = await run('slowheaders');
95 assert.deepEqual([slow.ok, slow.code, slow.what], [false, 'timeout', 'firstByteTimeoutMs'], JSON.stringify(slow));
96 const up = await run('uploadsteady');
97 assert.deepEqual([up.ok, up.frames], [true, 2], JSON.stringify(up));
98 const upStall = await run('uploadstall');
99 assert.deepEqual([upStall.ok, upStall.code, upStall.what], [false, 'timeout', 'idleTimeoutMs'], JSON.stringify(upStall));
100 // #273 heldTimeoutMs: the consumer holds the first frame (holdMs), longer than the 250 ms idle limit each time.
101 // Past a 600 ms hold limit it is cut as timeout/heldTimeoutMs; just under it, or with the limit off, it reads all 21.
102 const holdPast = await post('/timeouts', { url: `${base}/steady/r.git`, mode: 'steady', holdMs: 900, limits: { ...limits, heldTimeoutMs: 600 } });
103 assert.deepEqual([holdPast.ok, holdPast.code, holdPast.what, holdPast.limit], [false, 'timeout', 'heldTimeoutMs', 'heldTimeoutMs'], JSON.stringify(holdPast));
104 const holdUnder = await post('/timeouts', { url: `${base}/steady/r.git`, mode: 'steady', holdMs: 450, limits: { ...limits, heldTimeoutMs: 600 } });
105 assert.deepEqual([holdUnder.ok, holdUnder.frames], [true, 21], JSON.stringify(holdUnder));
106 const holdOff = await post('/timeouts', { url: `${base}/steady/r.git`, mode: 'steady', holdMs: 900, limits: { ...limits, heldTimeoutMs: 0 } });
107 assert.deepEqual([holdOff.ok, holdOff.frames], [true, 21], JSON.stringify(holdOff));
108 console.log(` workerd timeouts: steady ${steady.ms} ms ok, stall cut at ${stall.ms} ms, slow headers ${slow.ms} ms, upload stall ${upStall.ms} ms`);
109 } finally { server.closeAllConnections?.(); server.close(); }
110});
112test('workerd: platform features the pipeline relies on', { skip: !WORKERD }, async () => {
113 const f = await (await fetch(`http://127.0.0.1:${PORT}/features`)).json();
114 for (const k of ['DecompressionStream', 'CompressionStream', 'AbortSignalAny', 'AbortSignalTimeout', 'getRandomValues']) assert.equal(f[k], 'function', k);
115 assert.equal(f.deflateOk, true);
116});
118test('workerd: edit small file, 24 MB file, cache hit on second edit; git-verified', { skip: !WORKERD }, async () => {
119 const bare = makeBareRepo(root, 'e'); const work = join(root, 'we'); mkdirSync(work); initRepo(work);
120 const big = Buffer.alloc(24 << 20); for (let i = 0; i < big.length; i += 4096) big.write(`line ${i}\n`, i); big.write('MARK', 12 << 20);
121 commitFiles(work, bare, { 'a/b/c.txt': 'hello MARK world\n', 'big.bin': big }, 'seed');
122 const url = `${srv.url}/e.git`;
123 let r = await post('/edit', { url, path: 'a/b/c.txt', find: 'MARK', replace: 'WORKERD' });
124 assert.ok(r.results[0].ok, JSON.stringify(r.results[0]));
125 assert.equal(gitBuf(bare, ['cat-file', 'blob', 'main:a/b/c.txt']).toString(), 'hello WORKERD world\n');
126 assert.equal(git(bare, ['rev-parse', 'main']).trim(), r.results[0].newCommit);
127 r = await post('/edit', { url, path: 'big.bin', find: 'MARK', replace: 'WD' });
128 assert.ok(r.results[0].ok, JSON.stringify(r.results[0]));
129 assert.ok(r.results[0].pushBytes < 1500, 'delta push');
130 console.log(` 24MB edit under workerd: ${r.results[0].ms}ms, hasher=${r.blob[0]['git.edit.blob.hasher']}`);
131 assert.ok(r.roots[0]['mem.alloc.max_single'] <= 65536 && r.roots[0]['mem.alloc.max_single'] >= 4096, `max single alloc ${r.roots[0]['mem.alloc.max_single']} (workerd DecompressionStream chunks are 4 KiB)`);
132 const got = gitBuf(bare, ['cat-file', 'blob', 'main:big.bin']);
133 assert.equal(got.length, big.length - 2); assert.equal(got.subarray(12 << 20, (12 << 20) + 2).toString(), 'WD');
134 // second edit on the same path inside the same isolate: tree cache is module-scoped per request here (cache passed per /edit call), so this checks the edit, not the cache
135 r = await post('/edit', { url, path: 'a/b/c.txt', find: 'WORKERD', replace: 'AGAIN', n: 2 });
136 assert.ok(r.results[0].ok && !r.results[0].noop); assert.equal(r.results[1].code, 'match_count');
137 assert.deepEqual(fsckProblems(bare), []);
138 console.log(` small ${r.results[0].ms}ms; 24MB edit git-verified, max alloc ${r.roots[0]['mem.alloc.max_single']}`);
139});
141test('workerd: pack cache on caches.default + head hint (ls-refs skipped, CAS catches a stale hint)', { skip: !WORKERD }, async () => {
142 const bare = makeBareRepo(root, 'pc'); const work = join(root, 'wpc'); mkdirSync(work); initRepo(work);
143 commitFiles(work, bare, { 'a/b/c.txt': 'hello MARK world\n' }, 'seed');
144 const url = `${srv.url}/pc.git`;
145 const head = git(bare, ['rev-parse', 'main']).trim();
146 let r = await post('/edit', { url, path: 'a/b/c.txt', find: 'MARK', replace: 'H1', packCache: true, head });
147 assert.ok(r.results[0].ok, JSON.stringify(r.results[0]));
148 assert.equal(r.results[0].hint, 'used'); assert.equal(r.results[0].oldCommit, head);
149 assert.equal(git(bare, ['rev-parse', 'main']).trim(), r.results[0].newCommit);
150 // workerd standalone has no cache service bound: caches.default is present but never hits. The property that matters
151 // here is that the wrapper runs on the platform (tee, waitUntil, Headers) and reports MISS honestly rather than HIT?.
152 const s0 = r.results[0].packCache; assert.equal(s0.miss + s0.bypass > 0, true); assert.equal(s0.hit, 0);
153 assert.ok(r.roots[0]['git.edit.head.hint'] === head);
154 // stale hint, parallel mode (default): corrected by the overlapped ls-refs, one push, one root
155 git(work, ['fetch', '-q', bare, 'refs/heads/main']); git(work, ['reset', '-q', '--hard', 'FETCH_HEAD']);
156 commitFiles(work, bare, { 'other.txt': 'x\n' }, 'other');
157 let moved = git(bare, ['rev-parse', 'main']).trim();
158 r = await post('/edit', { url, path: 'a/b/c.txt', find: 'H1', replace: 'H2', packCache: true, head: r.results[0].newCommit });
159 assert.ok(r.results[0].ok, JSON.stringify(r.results[0]));
160 assert.equal(r.results[0].hint, 'stale'); assert.equal(r.results[0].oldCommit, moved);
161 assert.deepEqual(r.roots.map(x => x['git.edit.outcome']), ['ok']);
162 assert.equal(r.blob[0]['git.edit.blob.hasher'], 'digeststream', 'workerd has crypto.DigestStream: native SHA-1');
163 assert.equal(gitBuf(bare, ['cat-file', 'blob', 'main:a/b/c.txt']).toString(), 'hello H2 world\n');
164 assert.deepEqual(fsckProblems(bare), []);
165});
167test('workerd: Ed25519 signing through the platform WebCrypto; git verifies', { skip: !WORKERD }, async () => {
168 const bare = makeBareRepo(root, 'sg'); const work = join(root, 'wsg'); mkdirSync(work); initRepo(work);
169 commitFiles(work, bare, { 'f.txt': 'MARK\n' }, 'seed');
170 const r = await post('/edit', { url: `${srv.url}/sg.git`, path: 'f.txt', find: 'MARK', replace: 'SIGNED', sign: true });
171 assert.ok(r.results[0].ok, JSON.stringify(r.results[0])); assert.match(r.signer, /^ssh-ed25519 /);
172 const signers = join(root, 'signers'); writeFileSync(signers, `wd@x namespaces="git" ${r.signer}\n`);
173 const { spawnSync } = await import('node:child_process');
174 const v = spawnSync('git', ['-C', bare, '-c', 'gpg.format=ssh', '-c', 'gpg.ssh.program=ssh-keygen', '-c', `gpg.ssh.allowedSignersFile=${signers}`, 'verify-commit', r.results[0].newCommit], { encoding: 'utf8' });
175 assert.equal(v.status, 0, v.stderr); assert.match(v.stderr + v.stdout, /Good "git" signature/);
176});
178test('workerd: 10 concurrent writers in one isolate converge via cas_conflict retries', { skip: !WORKERD }, async () => {
179 const bare = makeBareRepo(root, 'c'); const work = join(root, 'wc'); mkdirSync(work); initRepo(work);
180 const files = {}; for (let i = 0; i < 10; i++) files[`f${i}.txt`] = `v0 MARK${i}\n`;
181 commitFiles(work, bare, files, 'seed');
182 const url = `${srv.url}/c.git`;
183 const rs = await Promise.all(Array.from({ length: 10 }, async (_, i) => {
184 for (let tries = 0; tries < 60; tries++) {
185 const r = await post('/edit', { url, path: `f${i}.txt`, find: `MARK${i}`, replace: `DONE${i}` });
186 const x = r.results[0]; if (x.ok) return { i, tries }; if (x.code !== 'cas_conflict') return { i, tries, fail: `${x.code} ${x.message}` };
187 }
188 return { i, fail: 'livelock' };
189 }));
190 for (const r of rs) assert.ok(!r.fail, JSON.stringify(r));
191 for (let i = 0; i < 10; i++) assert.equal(gitBuf(bare, ['cat-file', 'blob', `main:f${i}.txt`]).toString(), `v0 DONE${i}\n`);
192 assert.equal(git(bare, ['rev-list', '--count', 'main']).trim(), '11');
193 assert.ok(rs.some(r => r.tries > 0), 'contention actually occurred');
194 assert.deepEqual(fsckProblems(bare), []);
195 console.log(` retries: ${rs.map(r => r.tries).join(',')}`);
196});
198test('workerd: a 3xx is never followed (redirect: manual) on the GET or the POST; nothing reaches the other origin', { skip: !WORKERD }, async () => {
199 const listen = h => new Promise(ok => { const s = http.createServer(h); s.listen(0, '127.0.0.1', () => ok(s)); });
200 const seen = [];
201 const other = await listen((req, res) => { seen.push({ url: req.url, authorization: req.headers.authorization ?? null }); res.writeHead(200, { 'content-type': 'text/plain' }); res.end('x'); });
202 const red = await listen((req, res) => { res.writeHead(307, { location: `http://127.0.0.1:${other.address().port}${req.url}` }); res.end(); });
203 try {
204 const r = await post('/redirect', { url: `http://127.0.0.1:${red.address().port}/r.git`, auth: { token: 'ghp_workerdRedirect0123456789' } });
205 assert.equal(r.get.code, 'http', JSON.stringify(r.get)); assert.equal(r.get.status, 307);
206 assert.equal(r.post.code, 'http', JSON.stringify(r.post)); assert.equal(r.post.status, 307);
207 assert.match(r.post.message, /redirected to .*\/r\.git\/git-upload-pack; ply does not follow redirects/);
208 const plyHits = seen.filter(h => h.authorization !== 'Bearer workerd-follow-probe');
209 assert.deepEqual(plyHits, [], 'ply requests reached the redirect target');
210 // Not ply: what this workerd does under the default `follow` with an Authorization header, cross-origin (recorded).
211 const probe = seen.find(h => h.authorization === 'Bearer workerd-follow-probe') ?? seen.find(h => h.url.includes('info/refs'));
212 console.log(` workerd default follow, cross-origin: ${probe ? `target reached, Authorization ${probe.authorization ? 'FORWARDED' : 'stripped'}` : 'target not reached'} (${JSON.stringify(r.follow)})`);
213 } finally { other.close(); red.close(); }
214});
216test('workerd: a token given as the URL user authenticates the edit with the Authorization git sends; it reaches no span (#32)', { skip: !WORKERD }, async () => {
217 const bare = makeBareRepo(root, 'ui'); const work = join(root, 'wui'); mkdirSync(work); initRepo(work);
218 commitFiles(work, bare, { 'a.txt': 'hello MARK\n' }, 'seed');
219 const TOKEN = 'glpat-WorkerdUserOnlyToken';
220 const gate = await startAuthGate(srv.url);
221 try {
222 const url = `http://${TOKEN}@${new URL(gate.url).host}/ui.git`;
223 const { cred, config } = await gitUserinfoCred(work, url); // git decodes it; no credential in the URL git dials
224 const ls = await gitWithCred(work, ['ls-remote', `${gate.url}/ui.git`], cred, config);
225 assert.equal(ls.status, 0, ls.stderr);
226 const gitAuth = [...new Set(gate.seen.map(x => x.authorization).filter(Boolean))];
227 assert.deepEqual(gitAuth, [`Basic ${btoa(`${TOKEN}:`)}`]);
228 gate.seen.length = 0;
229 const r = await post('/edit', { url, path: 'a.txt', find: 'MARK', replace: 'WORKERD', dump: true });
230 assert.ok(r.results[0].ok, JSON.stringify(r.results[0]));
231 assert.equal(git(bare, ['rev-parse', 'main']).trim(), r.results[0].newCommit);
232 assert.deepEqual([...new Set(gate.seen.map(x => x.authorization))], gitAuth);
233 for (const s of [TOKEN, gitAuth[0].slice(6), `${TOKEN}@`]) assert.ok(!r.dump.includes(s), `${s} in a span`);
234 } finally { await gate.close(); }
235});
237test('workerd: readFile\'s blob stream, drained and cancelled; git.read.blob follows the root in a trace of its own (#35)', { skip: !WORKERD }, async () => {
238 const bare = makeBareRepo(root, 'rd'); const work = join(root, 'wrd'); mkdirSync(work); initRepo(work);
239 const big = Buffer.alloc(1 << 20); for (let i = 0; i < big.length; i += 4096) big.write(`line ${i}\n`, i);
240 commitFiles(work, bare, { 'big.bin': big }, 'seed');
241 for (const cancel of [false, true]) {
242 const r = await post('/read', { url: `${srv.url}/rd.git`, path: 'big.bin', cancel });
243 assert.ok(r.ok, JSON.stringify(r));
244 assert.equal(r.size, big.length);
245 if (cancel) assert.ok(r.bytes > 0 && r.bytes < big.length, `one chunk: ${r.bytes}`); else assert.equal(r.bytes, big.length);
246 const rootSpan = r.spans.find(s => s.name === 'git.read'), blob = r.spans.find(s => s.name === 'git.read.blob');
247 assert.ok(blob, 'the blob span ended');
248 assert.deepEqual([blob.parentSpanId, blob.traceId === rootSpan.traceId, blob.links, rootSpan.links], [null, false, [[rootSpan.spanId, 'follows_from']], [[blob.spanId, 'followed_by']]]);
249 assert.equal(blob.outcome, cancel ? 'cancelled' : 'ok');
250 assert.equal(r.spans.filter(s => s.name === 'git.read.blob').length, 1);
251 }
252});
254test('workerd: a limit hit inside readFile\'s blob stream reaches the reader as limit_exceeded, as on node (#144)', { skip: !WORKERD }, async () => {
255 const bare = makeBareRepo(root, 'rdcap'); const work = join(root, 'wrdcap'); mkdirSync(work); initRepo(work);
256 const big = randomBytes((1 << 20) + 1); // incompressible: the pack is over 1 MiB
257 commitFiles(work, bare, { 'big.bin': big }, 'seed');
258 const r = await post('/read', { url: `${srv.url}/rdcap.git`, path: 'big.bin', limits: { maxPackBytes: 1 << 20 } });
259 assert.deepEqual([r.ok, r.code, r.what, r.blob], [false, 'limit_exceeded', 'pack bytes', ['limit_exceeded']], JSON.stringify(r));
260});
262// #172: the streamed push under workerd. workerd ends an errored request body as if it were complete (measured: the
263// server sees a clean chunked end), so a pass 2 that refuses to finish the pack must leave git without a whole pack.
264test('workerd: pass 1 and pass 2 write buildPack\'s bytes under workerd\'s CompressionStream', { skip: !WORKERD }, async () => {
265 for (const half of [false, true]) {
266 const r = await post('/packwrite', { sizes: [0, 1, 16383, 16384, 16385, 65535, 65536, 65537, 200000, 1 << 20], half });
267 for (const c of r) assert.deepEqual([c.passes, c.built], [true, true], JSON.stringify(c));
268 }
269});
271test('workerd: a 4 MiB push streams its pack (duplex half; redirect manual, workerd refuses error) and lands; a pack changed between passes does not', { skip: !WORKERD }, async () => {
272 const bare = makeBareRepo(root, 'ps');
273 const r = await post('/push', { url: `${srv.url}/ps.git`, size: 4 << 20 });
274 assert.equal(r.ok, true, JSON.stringify(r));
275 assert.deepEqual(r.seen, [{ streamed: true, duplex: 'half', redirect: 'manual' }]);
276 assert.equal(git(bare, ['rev-parse', 'main']).trim(), r.commit);
277 assert.deepEqual(fsckProblems(bare), []);
278 const cut = makeBareRepo(root, 'pscut');
279 const m = await post('/push', { url: `${srv.url}/pscut.git`, size: 1 << 20, mutate: true });
280 assert.deepEqual([m.ok, m.code, m.original], [false, 'ambiguous', 'internal'], JSON.stringify(m));
281 assert.match(m.message, /second deflate pass/);
282 assert.equal(git(cut, ['for-each-ref']).trim(), '', 'git moved no ref');
283});
285test('workerd: pushPack streams a caller\'s pack and lands; a wrong length or a failed source does not, though workerd ends an errored body as if complete', { skip: !WORKERD }, async () => {
286 const bare = makeBareRepo(root, 'pp');
287 const r = await post('/push-pack', { url: `${srv.url}/pp.git`, size: 4 << 20, mode: 'ok' });
288 assert.equal(r.ok, true, JSON.stringify(r));
289 assert.deepEqual(r.seen, [{ streamed: true, duplex: 'half', redirect: 'manual' }]);
290 assert.equal(r.packBytes, r.whole);
291 assert.equal(git(bare, ['rev-parse', 'main']).trim(), r.commit);
292 assert.deepEqual(fsckProblems(bare), []);
293 for (const [mode, original] of [['short', 'bad_request'], ['errored', 'internal']]) {
294 const cut = makeBareRepo(root, `pp${mode}`);
295 const m = await post('/push-pack', { url: `${srv.url}/pp${mode}.git`, size: 1 << 20, mode });
296 assert.deepEqual([m.ok, m.code, m.original], [false, 'ambiguous', original], JSON.stringify(m));
297 assert.equal(git(cut, ['for-each-ref']).trim(), '', `${mode}: git moved no ref`);
298 }
299});
Diagnostics4 git calls · 241 ms
CallStatusSizeTime0241 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=145
git.response.cache=HIT
git.response.duration_ms=2
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 1020038 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=236
git.response.bytes=38434
git.response.cache=HIT
git.response.duration_ms=2
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=19912563f540228593df0c489082e5e2508e21e4
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=38434
git.pkt.payload.max=38339
git.sideband.band1.bytes=38338
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=63
git.pack.bytes=38338
git.pack.ofs_delta=0
git.pack.ref_delta=8
git.pack.chain.max=8
git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77
git.pack.full=55
Open pack map
fetch2007.2 KiB236 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=7348
git.response.cache=MISS
git.response.duration_ms=236
git.fetch.wants=d0590ee74bba9dc84b854e3155e85251a72e43dd
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=7348
git.pkt.payload.max=7327
git.sideband.band1.bytes=7326
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.git
Ref
refs/heads/main
Commit
19912563f540228593df0c489082e5e2508e21e4
cf-ray
a5e21e2daa45a87d
Request
a8cf3640…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format