fix: detect v1 client abort explicitly#6908
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves v1 workflow dispatch client-abort detection by introducing a dedicated abort tracker that uses request/socket/response signals, wiring the v1 API request object into dispatchWorkFlow, and adding targeted tests to distinguish normal response closure from premature client disconnects.
Changes:
- Add
createClientAbortTrackerutility to robustly detect premature client disconnects (req/res + socket events, snapshot checks). - Pass
reqintodispatchWorkFlowfor v1 dispatch paths so abort detection can observe request/socket lifecycle. - Add unit tests covering “close after finished” vs “close before finished” and socket-close scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| projects/app/src/pages/api/v1/chat/completions.ts | Parses request body once and forwards req into v1 workflow dispatch to enable socket-based abort tracking. |
| packages/service/core/workflow/dispatch/utils/clientAbort.ts | Introduces the v1 client-abort tracker (event-driven + snapshot-based) with cleanup support. |
| packages/service/core/workflow/dispatch/index.ts | Integrates the abort tracker into v1 checkIsStopping logic and ensures listeners are cleaned up in finally. |
| packages/service/test/core/workflow/dispatch/index.test.ts | Adds focused tests validating correct abort classification across close/finish/socket scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report
File CoverageNo changed files found. |
|
✅ Build Successful - Preview code-sandbox Image for this PR: 🕒 Time: 2026-05-09 18:19:41 (UTC+8) |
|
✅ Build Successful - Preview mcp_server Image for this PR: 🕒 Time: 2026-05-09 18:20:08 (UTC+8) |
|
✅ Admin Preview Image Ready! 🕒 Time: 2026-05-09 18:20:28 (UTC+8) |
|
✅ Build Successful - Preview fastgpt Image for this PR: 🕒 Time: 2026-05-09 18:21:21 (UTC+8) |
Summary
Tests