Skip to content

relay-gateway.e2e.test.ts lease-files relay test times out when run beside the daemon and leasing unit files #1412

Closed

Description

@V3RON

`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
```

Cause not looked at. Found while triaging #1410.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 7, 2026
  2. self-assigned this
    on Nov 7, 2026
  3. V3RON commented on Nov 7, 2026

    @V3RON
    ContributorAuthor

    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.

    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):

    async function uploadsOnWorker(directory: string) {
      const root = join(directory, "lease-files");
      const folders = await readdir(root).catch(() => []);
      const entries = await Promise.all(folders.map((folder) => readdir(join(root, folder))));
      return entries.flat().filter((entry) => entry.startsWith(".upload-")).length;
    }
    // new test, after feed.write:
    await poll(() => 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.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Side findings

    Written by an agent.

  4. removed their assignment
    on Nov 7, 2026
  5. added
    bug:ready
    fast-track
    and removed
    bug:new
    on Nov 7, 2026
  6. self-assigned this
    on Nov 7, 2026
  7. V3RON commented on Nov 7, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1416 (#1412)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

  8. added a commit that references this issue on Nov 10, 2026
    4f3b137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyfast-track

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions