Skip to content

refactor(proxy): 统一代理拒绝请求生命周期处理 - #266

Merged
g1331 merged 2 commits into
masterfrom
refactor/request-log-query-module
Aug 7, 2026
Merged

refactor(proxy): 统一代理拒绝请求生命周期处理#266
g1331 merged 2 commits into
masterfrom
refactor/request-log-query-module

Conversation

@g1331

@g1331 g1331 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

统一代理请求生命周期中的拒绝结果,确保上游调用前的拒绝请求保持现有 HTTP 契约,并正确释放队列、并发和取消资源。

Related Issue

Closes #260

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (code improvement without changing functionality)
  • Tests (adding or updating tests)
  • Build/CI (changes to build system or CI configuration)

Changes

  • 将无效或过期 API key、权限不足、无匹配上游、配额/并发限制、排队超时和客户端取消统一纳入 lifecycle seam。
  • 拒绝请求在上游 dispatch 前结束,不产生错误的成功计费或 recording 结果。
  • 统一记录拒绝阶段、失败原因、耗时、路由决策和资源释放结果。
  • 修正 queue admission、concurrency reservation、abort listener 与 failover reservation 的释放路径。
  • 将下游 abort 传播到上游 fetch,并区分 dispatch 前后的取消语义。
  • 增加基于 handleProxy 的生命周期行为测试。

Test Plan

  • Local tests pass (pnpm test:run)
  • Type check passes (pnpm exec tsc --noEmit)
  • Lint passes (pnpm lint)
  • Manual testing completed

Additional automated verification:

  • pnpm test:proxy-stability passed, including production build and proxy stability smoke checks.
  • pnpm format:check passed.

Checklist

  • Code follows the project's coding standards
  • Tests have been added where necessary
  • Documentation has been updated (if applicable)
  • Changes do not introduce security vulnerabilities
  • Commit messages follow conventions

Screenshots

Not applicable; this PR has no UI changes.

Additional Notes

  • Full suite result: 240 test files passed, 3588 tests passed, 1 skipped.
  • Lint completed with 0 errors and 11 non-blocking jsdoc/require-jsdoc warnings.
  • Production build completed successfully; Next.js emitted a Turbopack NFT tracing warning for the existing traffic-recording import path.

@g1331
g1331 force-pushed the refactor/request-log-query-module branch from dcae54e to d9d1d60 Compare August 7, 2026 07:22
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.22%. Comparing base (9239970) to head (c9f6019).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #266      +/-   ##
==========================================
+ Coverage   72.21%   72.22%   +0.01%     
==========================================
  Files         244      244              
  Lines       14315    14344      +29     
  Branches     4764     4771       +7     
==========================================
+ Hits        10337    10360      +23     
- Misses       2609     2613       +4     
- Partials     1369     1371       +2     
Flag Coverage Δ
verify 72.22% <86.66%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@g1331
g1331 merged commit 849f2ae into master Aug 7, 2026
14 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.

refactor(proxy): 收拢准入与上游调用前的拒绝结果

1 participant