Skip to content

fix(server): keep a finished worker's callback channel open for its last report - #245

Merged
morgan-wowk merged 1 commit into
TangleML:mainfrom
Hargun3:hargun/late-worker-reports
Dec 4, 2026
Merged

morgan-wowk merged 1 commit into
TangleML:mainfrom
Hargun3:hargun/late-worker-reports

Conversation

@Hargun3

@Hargun3 Hargun3 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

When Prime ends an external worker's tab, the gateway closes the tab's callback channel right away. Workers often send their last report a moment later, so that send_to_prime gets a 404 (unknown channel), the client shows "session not found", and Prime never sees the result.

The relay already knows how to deliver a report from a channel whose tab is gone (see the "falls back rather than losing the text" test in relayReport.test.ts). It just never got the chance, because the channel was already closed.

This keeps the channel open for ten minutes after the tab finishes, then closes it. The rest of retire() (roster entry, queued deliveries) is still released immediately.

How to test

  • pnpm --filter @tangent/server test passes (867/867). The updated gateway test fails if the channel is closed immediately again.
  • Typecheck, lint and prettier are clean.
  • On a local server: register an external tab, set it to completed, then call send_to_prime on its channel. On main this returns 404; on this branch it returns "Delivered to Prime."

Notes

  • A report sent after the ten minutes still gets the 404.
  • detached tabs keep their channel, as before.
  • Channels lost to a server restart are a separate issue (the relay registry is in memory).

…ast report

A worker often sends its final report just after Prime ends its tab. The
gateway closed the tab's callback channel immediately, so that report hit a
closed channel and was lost. The channel now closes ten minutes after the tab
goes terminal; until then a report on it reaches Prime through the relay's
existing fallback for a channel whose tab is gone.
@Hargun3
Hargun3 marked this pull request as ready for review December 4, 2026 09:45
@Hargun3
Hargun3 requested a review from a team as a code owner December 4, 2026 09:45
@morgan-wowk
morgan-wowk merged commit 50c9c22 into TangleML:main Dec 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants