Skip to content

πŸ”¨ chore(fetch-sse): enrich error context with provider, model, and network diagnostics#13468

Merged
arvinxx merged 1 commit intocanaryfrom
feat/enrich-fetch-error-context
Apr 1, 2026
Merged

πŸ”¨ chore(fetch-sse): enrich error context with provider, model, and network diagnostics#13468
arvinxx merged 1 commit intocanaryfrom
feat/enrich-fetch-error-context

Conversation

@arvinxx
Copy link
Copy Markdown
Member

@arvinxx arvinxx commented Apr 1, 2026

Summary

  • Enrich fetch error body with provider, model, apiMode, fetchOnClient, elapsedMs, networkStatus, and traceId for better debugging
  • Previously, TypeError: Failed to fetch errors only showed a useless minified stack trace with no actionable information
  • Now errors display enough context to quickly diagnose whether it's a network issue, provider issue, or client-side fetch problem

Fixes LOBE-6594

Changes

File Change
packages/fetch-sse/src/fetchSSE.ts Add FetchSSERequestContext interface; record fetch start time; enrich error body with request context, elapsedMs, and networkStatus
src/services/chat/index.ts Pass requestContext (provider, model, apiMode, fetchOnClient) to fetchSSE
src/store/chat/agents/createAgentExecutors.ts Append traceId to error body in onErrorHandle

Error body before vs after

Before:

{
  "name": "TypeError",
  "message": "Failed to fetch",
  "stack": "TypeError: Failed to fetch\n at create2 (app://renderer/assets/index-DRIaUz_L.js:599009:33)..."
}

After:

{
  "provider": "openai",
  "model": "gpt-4o",
  "apiMode": "chatCompletion",
  "fetchOnClient": false,
  "elapsedMs": 45,
  "networkStatus": true,
  "traceId": "xxx-yyy-zzz",
  "errorName": "TypeError",
  "errorMessage": "Failed to fetch"
}

Test plan

  • bun run type-check β€” no new type errors in changed files
  • Lint and pre-commit hooks pass
  • Verify enriched error body renders correctly in the error UI when a fetch failure occurs

πŸ€– Generated with Claude Code

…work diagnostics

When a fetch error occurs (e.g. TypeError: Failed to fetch), the error body now
includes provider, model, apiMode, fetchOnClient, elapsedMs, networkStatus, and
traceId to help diagnose issues instead of only showing a useless minified stack.

Fixes LOBE-6594

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Apr 1, 2026 6:37am

Request Review

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@lobehubbot
Copy link
Copy Markdown
Member

@ONLY-yours - This PR enriches fetch error context in the chat service and agent executors (fetch-sse streaming error handling). Please take a look.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 66.48%. Comparing base (cbc9bfc) to head (7359d85).
⚠️ Report is 5 commits behind head on canary.

Additional details and impacted files
@@           Coverage Diff            @@
##           canary   #13468    +/-   ##
========================================
  Coverage   66.48%   66.48%            
========================================
  Files        1972     1972            
  Lines      160137   160150    +13     
  Branches    16047    15341   -706     
========================================
+ Hits       106467   106482    +15     
+ Misses      53550    53548     -2     
  Partials      120      120            
Flag Coverage Ξ”
app 58.31% <100.00%> (+<0.01%) ⬆️
database 96.66% <ΓΈ> (ΓΈ)
packages/agent-runtime 88.98% <ΓΈ> (ΓΈ)
packages/context-engine 86.51% <ΓΈ> (ΓΈ)
packages/conversation-flow 92.36% <ΓΈ> (ΓΈ)
packages/file-loaders 87.02% <ΓΈ> (ΓΈ)
packages/memory-user-memory 66.68% <ΓΈ> (ΓΈ)
packages/model-bank 99.85% <ΓΈ> (ΓΈ)
packages/model-runtime 84.66% <ΓΈ> (ΓΈ)
packages/prompts 67.07% <ΓΈ> (ΓΈ)
packages/python-interpreter 92.90% <ΓΈ> (ΓΈ)
packages/ssrf-safe-fetch 0.00% <ΓΈ> (ΓΈ)
packages/utils 90.41% <ΓΈ> (ΓΈ)
packages/web-crawler 88.82% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Ξ”
Store 66.66% <100.00%> (+<0.01%) ⬆️
Services 49.27% <100.00%> (+0.05%) ⬆️
Server 66.35% <ΓΈ> (+<0.01%) ⬆️
Libs 51.03% <ΓΈ> (ΓΈ)
Utils 89.08% <ΓΈ> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7359d85326

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +329 to +330
errorMessage: error.message,
errorName: error.name,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve legacy unknown-error body keys for compatibility

The unknown-error branch now writes body.errorMessage/body.errorName instead of the established body.message/body.name fields, which is a breaking shape change for existing handlers that read body.message (and is already inconsistent with the current fetchSSE test expectations). This causes downstream error renderers/extractors to lose the primary message unless they are updated in lockstep; keep backward-compatible keys when enriching diagnostics.

Useful? React with πŸ‘Β / πŸ‘Ž.

@arvinxx arvinxx changed the title ✨ feat(fetch-sse): enrich error context with provider, model, and network diagnostics πŸ”¨ chore(fetch-sse): enrich error context with provider, model, and network diagnostics Apr 1, 2026
@arvinxx arvinxx merged commit 453db9f into canary Apr 1, 2026
35 checks passed
@arvinxx arvinxx deleted the feat/enrich-fetch-error-context branch April 1, 2026 06:58
@lobehubbot
Copy link
Copy Markdown
Member

❀️ Great PR @arvinxx ❀️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

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.

2 participants