Skip to content

test: web-integration reconnect flake — injected clock fires the 120s invoke timeout immediately #233

Closed as not planned

Description

@currentbits

electron/test/web-integration.test.js → "reconnect: server drop → re-auth → threads:list resync + synthetic threads:changed" fails on the current tree:

production first backoff is still 1s
120000 !== 1000
  at electron/test/web-integration.test.js:324

Pre-existing — reproduces on main as of aa4d1ca, both in the full npm run test:electron run and when the file is run alone, so it is not cross-test interference. Found while verifying #194; unrelated to that change.

The test asserts delays[0] === 1000 for the first reconnect backoff and the client schedules 120000 instead. Either wireClient's backoff schedule changed (120s looks like a max/ceiling being used as the first delay) and the test was never updated, or the production-vs-test branch that picks the schedule is no longer taking the production path under the test harness. Worth deciding which is right before touching the assertion — a real 2-minute first reconnect delay would be a user-visible regression in the web client, not a test bug.

Activity

  1. added
    plan:todo
    bug
    on Aug 17, 2026
  2. changed the title [-]test: web-integration reconnect asserts a 1s first backoff, gets 120000[/-] [+]test: web-integration reconnect flake — injected clock fires the 120s invoke timeout immediately[/+] on Aug 18, 2026
  3. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    Current failure (updated 2026-08-18)

    The original assertion (delays[0] === 1000, got 120000) was patched to delays.includes(1000) in electron/test/web-integration.test.js. The test still fails, but the error is now:

    Timed out after 120000ms: threads:list
        at src/wireClient.ts:153
        at electron/test/web-integration.test.js:298
    

    The whole test lasts ~110–140ms, so this is not a real 120s wait. The injected setTimeout fires the callback with setTimeout(fn, 0) once allowReconnect is true.

    What the test does

    1. First api.threads.list() — allowReconnect is false, so the invoke timeout is a dummy and this call usually succeeds.
    2. Flip allowReconnect = true, close the server-side sockets, wait for threads:changed.
    3. Last api.threads.list() — now the same injected clock schedules INVOKE_TIMEOUT_MS (120000) as setTimeout(fn, 0). That timer races the WebSocket reply and usually wins, rejecting with the 120s message.

    Root cause is unchanged: one injected clock is used for both reconnect backoff (MIN_BACKOFF_MS = 1000) and invoke timeout (INVOKE_TIMEOUT_MS = 120000). Making reconnect instant also makes every invoke expire instantly.

    Flake, not red-on-every-run

    Same SHA family, same test:

    run result
    Windows hardening branch 32117186703 macos test fail (107ms, this error)
    drag-and-drop PR 32121422998 macos test fail (136ms, this error)
    main merge of #473 32121797100 macos test pass

    So it is a race (timeout vs reply), not a permanent assertion mismatch.

    Fix direction

    Do not fire every timer at 0ms. Only collapse the reconnect backoff. The invoke timeout must stay a real (or dummy-never-fire) timer, or the test must use a clock that distinguishes the two.

  4. currentbits commented on Aug 20, 2026

    @currentbits
    OwnerAuthor

    Duplicate of #620, which has the actual mechanism for this exact failure: one injected setTimeout seam in wireClient serves both scheduleReconnect() backoff and invoke()s INVOKE_TIMEOUT_MS, so the test collapsing the backoff also fires the 120 s abort at 0 ms.

    Both candidate causes guessed here were wrong - the production first backoff is still 1000 ms and the production branch is being taken. Closing in favour of #620.

  5. added
    plan:done
    and removed
    plan:todo
    on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions