fix(happy-cli,happy-server): avoid false vendor token timeouts during connect#986
Open
wang-kaopu wants to merge 2 commits intoslopus:mainfrom
Open
fix(happy-cli,happy-server): avoid false vendor token timeouts during connect#986wang-kaopu wants to merge 2 commits intoslopus:mainfrom
wang-kaopu wants to merge 2 commits intoslopus:mainfrom
Conversation
… connect (slopus#983) * switch vendor token registration to a long-task handshake with task polling and heartbeats * add CLI and server regression coverage for progress, stall, and failure paths
There was a problem hiding this comment.
Pull request overview
This PR updates the vendor token registration flow used by happy connect to avoid client-side timeouts by switching from a single blocking request to a server-tracked long-task handshake that the CLI can poll and display progress for.
Changes:
- Server: change
POST /v1/connect/:vendor/registerto return202 Acceptedwith task metadata and addGET /v1/tasks/:taskIdfor polling task status. - Server: introduce an in-memory long-task store with stage/state tracking and heartbeat updates during persistence.
- CLI: update
registerVendorToken()to poll task status with idle/absolute timeouts and surface stage progress output; add regression tests and API docs updates.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/happy-server/sources/app/api/routes/connectRoutes.ts | Converts vendor token registration into an async long-task + adds task status polling route. |
| packages/happy-server/sources/app/api/routes/connectRoutes.test.ts | Adds tests for accepted→running→succeeded flow, heartbeat updates, and failure surfacing. |
| packages/happy-server/sources/app/api/longTaskStore.ts | Adds in-memory task store, TTL pruning, and heartbeat helper. |
| packages/happy-cli/src/commands/connect.ts | Adds CLI progress output and passes onProgress callback into registration call. |
| packages/happy-cli/src/commands/connect.test.ts | Tests progress callback wiring and de-duplication of stage output. |
| packages/happy-cli/src/api/api.ts | Implements long-task polling logic for vendor registration (202 handling, progress, stall detection). |
| packages/happy-cli/src/api/api.test.ts | Adds tests for long-task completion, stalling, and failure behavior. |
| docs/api.md | Documents the new 202 + task polling contract. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e9300d8 to
1a7a53f
Compare
Contributor
Author
|
Follow-up update after addressing Copilot robustness feedback. Additional changes on top of the original long-task flow:
Validation run locally:
Current head:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #983.
Summary
happy connect codexcould fail withtimeout of 5000ms exceededeven when vendor token registration was still progressing normally. The old flow treated registration as a single synchronous HTTP call with a hardcoded 5s client timeout, so it could not distinguish a slow-but-active request from a genuinely stalled one.This change converts vendor token registration into a small long-task handshake for the
connect registerpath. The server now accepts the work, tracks task stage and heartbeat in memory, and exposes task status for polling. The CLI waits on observable progress instead of a fixed request timeout, and reports task stages while waiting.What Changed
registerVendorToken()to an activity-aware long-task wait loop in the CLIPOST /v1/connect/:vendor/registerto return202 Acceptedwith task metadataGET /v1/tasks/:taskIdfor task status pollingValidation
happy-cliandhappy-serverKnown Limitation
The long-task store is intentionally in-memory for this first rollout. That keeps the registration path lightweight for a single-process foreground wait flow, but tasks do not survive server restarts and are not shared across multiple server instances yet.