Skip to content

fix(core): dev-mode warnings for silently swallowed callback errors#195

Merged
RtlZeroMemory merged 2 commits intomainfrom
guardrails/dev-warnings
Feb 25, 2026
Merged

fix(core): dev-mode warnings for silently swallowed callback errors#195
RtlZeroMemory merged 2 commits intomainfrom
guardrails/dev-warnings

Conversation

@RtlZeroMemory
Copy link
Copy Markdown
Owner

@RtlZeroMemory RtlZeroMemory commented Feb 25, 2026

Summary

  • Add warnDev() calls to all silent catch blocks across dropdown routing, overlay shortcuts, mouse routing, effect cleanups, and widget callbacks
  • Errors in user callbacks (onClose, onSelect, effect cleanups) were completely invisible — now emit console.warn in dev mode
  • Zero behavior change in production (NODE_ENV=production disables all warnings)

Files changed

  • runtime/router/dropdown.ts — 3 catch blocks
  • widgetRenderer/overlayShortcuts.ts — 4 catch blocks
  • widgetRenderer/mouseRouting.ts — 5 catch blocks
  • runtime/instances.ts — effect cleanup + stale closure warnings
  • widgets/codeEditorSyntax.ts — custom tokenizer error
  • widgets/pagination.ts — decodeURIComponent error
  • app/widgetRenderer.ts — generic callback wrapper

Summary by CodeRabbit

  • New Features

    • Added development-mode error diagnostics throughout core modules including widget rendering, runtime, and routing. Error conditions previously silently swallowed now emit warnings in development mode.
  • Bug Fixes

    • Enhanced error handling in code editor tokenization and pagination modules with explicit error reporting in development mode.

Effect cleanups, dropdown/overlay callbacks, and widget event handlers
that throw are caught to preserve routing determinism, but the errors
were completely invisible. Now emits console.warn in dev mode so
developers can see when their callbacks throw.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

Warning

Rate limit exceeded

@RtlZeroMemory has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between cc14312 and 32acbc1.

📒 Files selected for processing (5)
  • packages/core/src/app/widgetRenderer.ts
  • packages/core/src/app/widgetRenderer/mouseRouting.ts
  • packages/core/src/runtime/instances.ts
  • packages/core/src/runtime/router/dropdown.ts
  • packages/core/src/widgets/pagination.ts
📝 Walkthrough

Walkthrough

This PR adds development-mode diagnostic utilities (DEV_MODE flag and warnDev function) across the codebase to surface previously silent errors. Exception handlers that previously swallowed errors now emit console warnings during development, while production behavior remains unchanged.

Changes

Cohort / File(s) Summary
Widget Renderer Error Diagnostics
packages/core/src/app/widgetRenderer.ts, packages/core/src/app/widgetRenderer/mouseRouting.ts, packages/core/src/app/widgetRenderer/overlayShortcuts.ts
Added development-mode error logging to callback handlers in widget rendering paths. Silent catch blocks for dropdown, layer backdrop, and overlay callbacks now emit warnings via warnDev when exceptions occur, surfacing previously hidden errors during development without affecting production.
Runtime and Router Diagnostics
packages/core/src/runtime/instances.ts, packages/core/src/runtime/router/dropdown.ts
Introduced warnDev logging in cleanup paths and dropdown callback handlers. Enhanced diagnostics for cleanup errors, stale closure state updates, and dropdown navigation callback failures, while preserving silent swallowing behavior in production.
Widget Parsing Diagnostics
packages/core/src/widgets/codeEditorSyntax.ts, packages/core/src/widgets/pagination.ts
Added development-time error reporting for widget-specific parsing failures. Code syntax tokenization and segment decoding errors now log warnings in development mode instead of silently failing, with fallback to safe defaults.

Possibly related PRs

Poem

🐰 Whispers in the warren speak of hidden bugs,
Now caught and warned when dev-mode tugs,
Silent errors bloom—no more shall they hide,
Shining bright when developers peek inside!

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding development-mode warnings for errors that were previously silently swallowed in callback handlers across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch guardrails/dev-warnings

Comment @coderabbitai help to get the list of available commands and usage tips.

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

ℹ️ 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 thread packages/core/src/app/widgetRenderer/mouseRouting.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/core/src/app/widgetRenderer.ts`:
- Around line 418-420: The catch block formatting fails CI; extract the error
message into a short local variable and call warnDev with that variable to make
the line shorter and prettier. Specifically, inside the catch for the widget
renderer replace the long inline ternary with e.g. const msg = e instanceof
Error ? e.message : String(e); then call if (DEV_MODE) warnDev(`[rezi] widget
callback threw: ${msg}`); and finally return false; — update the catch around
the widget renderer callback (references: DEV_MODE, warnDev) to follow this
pattern so formatting checks pass.

In `@packages/core/src/app/widgetRenderer/mouseRouting.ts`:
- Around line 359-361: Reformat the catch warning to avoid the CI formatting
error by extracting the error message into a temporary constant and then passing
a simple template string to warnDev; e.g., inside the catch block for onSelect,
compute const errMsg = e instanceof Error ? e.message : String(e) and then call
warnDev(`[rezi] onSelect callback threw: ${errMsg}`) so the line is shorter and
clearer.

In `@packages/core/src/runtime/instances.ts`:
- Around line 390-391: Replace the template literal passed to warnDev with a
plain string literal to satisfy the lint rule; in the branch where you log the
stale-closure warning (the call to warnDev inside the setState handling when
instance generation changed), change the argument from a backtick string to a
double- or single-quoted string (e.g., "[rezi] setState called from stale
closure (instance generation changed)").

In `@packages/core/src/runtime/router/dropdown.ts`:
- Around line 95-97: Reformat the catch block handling onSelect so it complies
with the project's formatter: replace the single long line with a properly
wrapped block that calls warnDev(...) across lines (e.g., compute the message or
the error string on its own line and then pass a template string to warnDev),
keeping the existing conditional extraction of the message (e instanceof Error ?
e.message : String(e)) and the original text `[rezi] onSelect callback threw:`;
target the catch block around the onSelect invocation where warnDev is called.

In `@packages/core/src/widgets/pagination.ts`:
- Around line 52-54: Replace the template literal warnDev call in the catch
block with a comma-separated call so the logger receives the static message and
the error value separately; update the warnDev invocation in
packages/core/src/widgets/pagination.ts (the catch around decodeURIComponent) to
use warnDev('[rezi] pagination decodeURIComponent failed:', e instanceof Error ?
e.message : String(e)) and keep the subsequent return null.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff26087 and cc14312.

📒 Files selected for processing (7)
  • packages/core/src/app/widgetRenderer.ts
  • packages/core/src/app/widgetRenderer/mouseRouting.ts
  • packages/core/src/app/widgetRenderer/overlayShortcuts.ts
  • packages/core/src/runtime/instances.ts
  • packages/core/src/runtime/router/dropdown.ts
  • packages/core/src/widgets/codeEditorSyntax.ts
  • packages/core/src/widgets/pagination.ts

Comment thread packages/core/src/app/widgetRenderer.ts
Comment thread packages/core/src/app/widgetRenderer/mouseRouting.ts
Comment thread packages/core/src/runtime/instances.ts Outdated
Comment thread packages/core/src/runtime/router/dropdown.ts
Comment thread packages/core/src/widgets/pagination.ts
@RtlZeroMemory RtlZeroMemory merged commit 1192820 into main Feb 25, 2026
31 checks passed
@RtlZeroMemory RtlZeroMemory deleted the guardrails/dev-warnings branch February 25, 2026 04:54
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.

1 participant