frontend: isolate page init steps so one failure doesn't abort the rest#3534
frontend: isolate page init steps so one failure doesn't abort the rest#3534reakaleek wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 44 minutes and 34 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Elastic.Documentation.Site/Assets/main.ts`:
- Around line 58-72: The runInitSteps function accepts init functions but does
not await them, causing async function errors to escape the try/catch block as
unhandled promise rejections. Make the runInitSteps function itself async, await
the init() call inside the try block, and update the function signature to
accept functions that return either void or Promise<void>. Additionally, update
all event handlers and callers that invoke runInitSteps to await the returned
promise so that error handling works correctly for both synchronous and
asynchronous initialization steps.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: fca9bbd5-05b8-42e4-891a-7ec41a9b8553
📒 Files selected for processing (1)
src/Elastic.Documentation.Site/Assets/main.ts
…ections initMermaid is async; without await the try/catch silently misses its rejected promise. Event handlers are left synchronous — the browser ignores listener return values and runInitSteps never rejects externally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why
The init chain in
main.tsruns a sequence of functions on everyhtmx:loadevent with no error isolation. A single thrown exception propagates out of the event listener and silently skips every subsequent init call — meaning a bug ininitTocNavwould also break copy buttons, tabs, math rendering, and everything else on the page.What
Adds a
runInitStepshelper that iterates a named list of init functions and wraps each call in a try/catch. Failures are logged toconsole.error(always visible in DevTools) and to the existinglogErrorfromtelemetry/logging.ts(structured, sent to the backend when telemetry is enabled). BothDOMContentLoadedandhtmx:loadblocks are converted to use it.The
?editquery-param inline block is extracted intoapplyEditParamso it fits the same guarded list.How
Step names are passed as explicit strings rather than derived from
fn.nameso they survive Parcel minification and remain stable in production error logs.