You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
relay-gateway.e2e.test.ts lease-files relay test times out when run beside the daemon and leasing unit files #1412
`src/daemon/relay-gateway.e2e.test.ts` > "through a gateway, a lease holder's PUT, GET, list and DELETE reach the lease's worker and answer as on a worker" failed once at 9.9 s on main plus a change to `src/core/registry.ts` only. The same file passed alone (36/36) and in a second run of the same set.
```
pnpm exec vitest run --project unit src/core/registry-state-db.test.ts src/daemon src/leasing
× through a gateway, a lease holder's PUT, GET, list and DELETE reach the lease's worker and answer as on a worker 9939ms
```
Confirmed. It is a race in the test's own step, not a timeout and not a product bug. With two copies of the reported set running at once it failed 6 of 6 times.
pnpm exec vitest run --project unit src/core/registry-state-db.test.ts src/daemon src/leasing # two copies at once
AssertionError: expected 201 to be 409 ❯ src/daemon/relay-gateway.e2e.test.ts:557
Logging showed the holder's PUT itself answered 409 FILE_BUSY.
The new test on bug/1412-repro, src/daemon/relay-gateway.e2e.test.ts > "through a gateway, a PUT of a name whose upload is still arriving gets 409 FILE_BUSY, even when that upload reaches the worker after the PUT was sent", fails every time on an idle machine. Its holder's PUT goes through a proxy that holds the bytes back 500 ms:
pnpm exec vitest run --project unit src/daemon/relay-gateway.e2e.test.ts -t "still arriving"
AssertionError: expected 201 to be 409 (second.status)
Root cause
Defect, in the test. At src/daemon/relay-gateway.e2e.test.ts:556, await feed.write(...) only means fetch has taken the first byte. It does not mean the worker's LeaseFileStore.put (src/lease-files/store.ts:200) has taken the name. Under load, the first probe PUT can reach the worker first and take busy.bin. The holder's PUT then gets 409 and ends. After that nobody holds the name, so every later probe gets 201 until the 5 s poll gives up. The store keeps one writer per name, as its manual says.
Simplest fix
Wait until the upload is on the worker before sending the probe. Prove FILE_BUSY only in the new test (testing rule 7):
asyncfunctionuploadsOnWorker(directory: string){constroot=join(directory,"lease-files");constfolders=awaitreaddir(root).catch(()=>[]);constentries=awaitPromise.all(folders.map((folder)=>readdir(join(root,folder))));returnentries.flat().filter((entry)=>entry.startsWith(".upload-")).length;}// new test, after feed.write:awaitpoll(()=>uploadsOnWorker(rig.worker.directory)).toBe(1);// big test: delete the busy step (:549-559) and `await feed.close(); await holding;`
pnpm exec vitest run --project unit src/daemon/relay-gateway.e2e.test.ts → 37 passed
reported set, two copies at once, 3 rounds → no relay-gateway failure (6/6)
Alternatives rejected
A longer poll timeout: the holder's PUT has already ended, so every probe gets 201 however long it waits.
Waiting on channelsOpened(): an open link channel does not mean the worker's store holds the name.
Changing the store: it does what its manual says.
Risk
The wait depends on the .upload-<id> layout the lease-files manual states.
After the fix the big test no longer checks FILE_BUSY. Only the new test does.
Activity
V3RON commentedon Nov 7, 2026
Reproduction
Confirmed. It is a race in the test's own step, not a timeout and not a product bug. With two copies of the reported set running at once it failed 6 of 6 times.
Logging showed the holder's PUT itself answered
409 FILE_BUSY.The new test on
bug/1412-repro,src/daemon/relay-gateway.e2e.test.ts> "through a gateway, a PUT of a name whose upload is still arriving gets 409 FILE_BUSY, even when that upload reaches the worker after the PUT was sent", fails every time on an idle machine. Its holder's PUT goes through a proxy that holds the bytes back 500 ms:Root cause
Defect, in the test. At
src/daemon/relay-gateway.e2e.test.ts:556,await feed.write(...)only means fetch has taken the first byte. It does not mean the worker'sLeaseFileStore.put(src/lease-files/store.ts:200) has taken the name. Under load, the first probe PUT can reach the worker first and takebusy.bin. The holder's PUT then gets 409 and ends. After that nobody holds the name, so every later probe gets 201 until the 5 s poll gives up. The store keeps one writer per name, as its manual says.Simplest fix
Wait until the upload is on the worker before sending the probe. Prove FILE_BUSY only in the new test (testing rule 7):
Alternatives rejected
channelsOpened(): an open link channel does not mean the worker's store holds the name.Risk
.upload-<id>layout the lease-files manual states.Fast track
Side findings
Written by an agent.
test: a PUT of a busy name gets 409 even when the upload reaches the …
fix(test): the late-upload test's title and comment say what it does (#…
V3RON commentedon Nov 7, 2026
Delivery run
Merged: #1416 (#1412)
Parked: none
Waiting: none
Decided: none
Written by an agent.
fix(test): a gateway file test waits for the upload to reach the work…