Skip to content

fix: detect v1 client abort explicitly#6908

Merged
c121914yu merged 1 commit into
labring:mainfrom
c121914yu:codex-client-abort-tracker
May 9, 2026
Merged

fix: detect v1 client abort explicitly#6908
c121914yu merged 1 commit into
labring:mainfrom
c121914yu:codex-client-abort-tracker

Conversation

@c121914yu
Copy link
Copy Markdown
Collaborator

Summary

  • add a dedicated client abort tracker for v1 workflow dispatch
  • pass the v1 API request into workflow dispatch so abort detection can use request/socket events
  • cover normal response close vs premature client abort cases in workflow dispatch tests

Tests

  • pnpm --filter @fastgpt/service test test/core/workflow/dispatch/index.test.ts

Copilot AI review requested due to automatic review settings May 9, 2026 10:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 createClientAbortTracker utility to robustly detect premature client disconnects (req/res + socket events, snapshot checks).
  • Pass req into dispatchWorkFlow for 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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 14.03% 1140 / 8122
🔵 Statements 14.02% 1195 / 8521
🔵 Functions 12.53% 245 / 1954
🔵 Branches 11.98% 536 / 4472
File CoverageNo changed files found.
Generated in workflow #150 for commit cc0e9b6 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Build Successful - Preview code-sandbox Image for this PR:

ghcr.io/labring/fastgpt-pr:code-sandbox_cc0e9b63068a5620eb3c394c7655676a5aa24f42

🕒 Time: 2026-05-09 18:19:41 (UTC+8)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Build Successful - Preview mcp_server Image for this PR:

ghcr.io/labring/fastgpt-pr:mcp_server_cc0e9b63068a5620eb3c394c7655676a5aa24f42

🕒 Time: 2026-05-09 18:20:08 (UTC+8)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Admin Preview Image Ready!

ghcr.io/labring/fastgpt-pr:admin_cc0e9b63068a5620eb3c394c7655676a5aa24f42

🕒 Time: 2026-05-09 18:20:28 (UTC+8)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Build Successful - Preview fastgpt Image for this PR:

ghcr.io/labring/fastgpt-pr:fastgpt_cc0e9b63068a5620eb3c394c7655676a5aa24f42

🕒 Time: 2026-05-09 18:21:21 (UTC+8)

@c121914yu c121914yu merged commit 747c9ca into labring:main May 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants