Skip to content

fix(stream): add logging to empty catch blocks in stream error handling - #8143

Merged
diegosouzapw merged 5 commits into
diegosouzapw:release/v3.8.49from
chirag127:fix/stream-issues
Jul 23, 2026
Merged

diegosouzapw merged 5 commits into
diegosouzapw:release/v3.8.49from
chirag127:fix/stream-issues

Conversation

@chirag127

@chirag127 chirag127 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces silent empty catch blocks with contextual logging across the stream subsystem, and externalizes sql.js in next.config.mjs to suppress build warnings.

Scope note (maintainer edit): this PR is scoped to logging hygiene only. Two unrelated hunks that had ended up on this branch (a targetExhaustion.ts 401 auth-exhaustion change and a modelFamilyFallback.ts candidate-skip change, tracked separately as #8133 and #8134) have been reverted back to the release baseline here so this PR stays focused and doesn't carry a regression the other two changes introduced against tests/unit/kiro-claude-sonnet-5-2267.test.ts. Those two changes should be proposed in their own PR(s).

Changes

open-sse/utils/stream.ts

  • Log errors in onComplete callbacks (lines 929, 1112, 2451, 2567, 2723)
  • Log errors in onFailure callbacks (lines 929, 1112, 2542)
  • All logging uses console.debug with [STREAM] prefix and model context

open-sse/utils/streamHandler.ts

  • Log trackPendingRequest decrement failures (line 249)
  • Log onError callback failures (line 336)
  • Log stall watchdog triple-catch failures (lines 667, 673, 677)
  • Add comments to intentional controller.close() catches (lines 537, 546, 558)

open-sse/executors/cursor.ts

  • Log KV blob write failures (lines 431, 438)
  • Log exec server event write failures (line 461, 517)
  • Add comments to intentional H2 lifecycle catches (lines 837, 861, 869, 917, 1007)

next.config.mjs

  • Add sql.js to serverExternalPackages to suppress 20+ build warnings

src/lib/db/adapters/sqljsAdapter.ts

Issues Fixed

Testing

  • npm run typecheck:core passes
  • ESLint passes on all modified files
  • Prettier formatting applied
  • No behavioral changes in the logging-hygiene hunks -- only logging/comments added to existing catch blocks
  • Added tests/unit/stream-handler-catch-logging-8143.test.ts: regression guard proving the stall-watchdog's handleError catch now logs via console.debug instead of silently swallowing
  • tests/unit/kiro-claude-sonnet-5-2267.test.ts passes (was regressed by the now-reverted modelFamilyFallback.ts hunk; confirmed green after the revert)

- targetExhaustion: skip remaining same-provider models on 401 auth failure
  (prevents opencode-zen noauth cascade wasting retry attempts) (#8133)
- modelFamilyFallback: skip unsupported models in T5 fallback chain
  (prevents GitHub provider trying deprecated claude-opus-4.8/4.7) (#8134)
- sqljsAdapter: split package.json resolve string to suppress Next.js
  Can't resolve warning at build time (#8135)
@chirag127
chirag127 requested a review from diegosouzapw as a code owner July 22, 2026 13:14
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

- stream.ts: Log errors in onComplete/onFailure callbacks (lines 929, 1112, 2451, 2536, 2561, 2717)
- streamHandler.ts: Log errors in stall watchdog and trackPendingRequest (lines 249, 334, 657, 663, 667)
- cursor.ts: Add comments to intentional H2 lifecycle catches, log KV/exec errors
- next.config.mjs: Externalize sql.js to suppress build warnings

Closes #8138, #8139, #8140, #8141, #8142

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

Copy link
Copy Markdown

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: a8be93402f

ℹ️ 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 +100 to +105
!providerExhausted &&
result.status === 401 &&
Boolean(provider && provider !== "unknown") &&
!hasPerModelQuota(provider, rawModel);

if (providerExhausted || authExhausted) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Scope 401 exhaustion to the failed connection

When a combo has multiple active accounts for the same non-per-model provider, a single expired or invalid account can return 401 here and exhaustedProviders.add(provider) will cause every later target for that provider to be skipped for the rest of the request, including targets with different connectionIds that still have valid credentials. The comment says this is for “all accounts” being unavailable, but the predicate only checks the status/provider; scope the 401 to exhaustedConnections when a connection is known, or only provider-exhaust after proving all accounts are unavailable.

AGENTS.md reference: open-sse/services/AGENTS.md:L11-L13

Useful? React with 👍 / 👎.

@chirag127 chirag127 changed the title fix(combo,model-fallback,sqljs): three stream-reliability fixes fix(stream): add logging to empty catch blocks in stream error handling Jul 22, 2026
…ustion/fallback hunks

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
rafaumeu and others added 2 commits July 23, 2026 04:39
…n-growth

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.49 to main July 23, 2026 07:48
@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.49 July 23, 2026 07:48
@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks, @chirag127! 🙏 Merged the logging-hygiene scope (console.debug on the stream-subsystem empty catch blocks + sql.js externalize). Dropped the two undisclosed behavioral hunks that were out of scope — the #8133 401 auth-exhaustion branch and the #8134 family-fallback filter (which regressed kiro-claude-sonnet-5-2267). Rebaselined stream.ts file-size for the legitimate logging own-growth. If you'd like the #8133/#8134 changes, please resubmit them as separately-tested PRs.

@diegosouzapw
diegosouzapw merged commit 8565954 into diegosouzapw:release/v3.8.49 Jul 23, 2026
2 checks passed
@chirag127
chirag127 deleted the fix/stream-issues branch July 26, 2026 14:28
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…ng (diegosouzapw#8143)

* fix(combo,model-fallback,sqljs): three stream-reliability fixes

- targetExhaustion: skip remaining same-provider models on 401 auth failure
  (prevents opencode-zen noauth cascade wasting retry attempts) (diegosouzapw#8133)
- modelFamilyFallback: skip unsupported models in T5 fallback chain
  (prevents GitHub provider trying deprecated claude-opus-4.8/4.7) (diegosouzapw#8134)
- sqljsAdapter: split package.json resolve string to suppress Next.js
  Can't resolve warning at build time (diegosouzapw#8135)

* fix(stream): add logging to empty catch blocks in stream error handling

- stream.ts: Log errors in onComplete/onFailure callbacks (lines 929, 1112, 2451, 2536, 2561, 2717)
- streamHandler.ts: Log errors in stall watchdog and trackPendingRequest (lines 249, 334, 657, 663, 667)
- cursor.ts: Add comments to intentional H2 lifecycle catches, log KV/exec errors
- next.config.mjs: Externalize sql.js to suppress build warnings

Closes diegosouzapw#8138, diegosouzapw#8139, diegosouzapw#8140, diegosouzapw#8141, diegosouzapw#8142

* refactor(stream): scope PR to logging hygiene, drop out-of-scope exhaustion/fallback hunks

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* chore(quality): rebaseline stream.ts for diegosouzapw#8143 empty-catch logging own-growth

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: rafaumeu <rafael.zendron22@gmail.com>
Co-authored-by: chirag127 <chirag127@users.noreply.github.com>
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ng (diegosouzapw#8143)

* fix(combo,model-fallback,sqljs): three stream-reliability fixes

- targetExhaustion: skip remaining same-provider models on 401 auth failure
  (prevents opencode-zen noauth cascade wasting retry attempts) (diegosouzapw#8133)
- modelFamilyFallback: skip unsupported models in T5 fallback chain
  (prevents GitHub provider trying deprecated claude-opus-4.8/4.7) (diegosouzapw#8134)
- sqljsAdapter: split package.json resolve string to suppress Next.js
  Can't resolve warning at build time (diegosouzapw#8135)

* fix(stream): add logging to empty catch blocks in stream error handling

- stream.ts: Log errors in onComplete/onFailure callbacks (lines 929, 1112, 2451, 2536, 2561, 2717)
- streamHandler.ts: Log errors in stall watchdog and trackPendingRequest (lines 249, 334, 657, 663, 667)
- cursor.ts: Add comments to intentional H2 lifecycle catches, log KV/exec errors
- next.config.mjs: Externalize sql.js to suppress build warnings

Closes diegosouzapw#8138, diegosouzapw#8139, diegosouzapw#8140, diegosouzapw#8141, diegosouzapw#8142

* refactor(stream): scope PR to logging hygiene, drop out-of-scope exhaustion/fallback hunks

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* chore(quality): rebaseline stream.ts for diegosouzapw#8143 empty-catch logging own-growth

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: rafaumeu <rafael.zendron22@gmail.com>
Co-authored-by: chirag127 <chirag127@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants