Skip to content

fix(analytics): drop chunk-load errors from PostHog error tracking - #556

Merged
jplacht merged 1 commit into
mainfrom
fix/chunk-load-unhandled-rejection
Oct 2, 2026
Merged

jplacht merged 1 commit into
mainfrom
fix/chunk-load-unhandled-rejection

Conversation

@jplacht

@jplacht jplacht commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What and why

After a deploy, a tab still on the old bundle fails to load a removed lazy chunk when it navigates programmatically (e.g. router.push("/") on session end or logout). chunkReload already handles the failure via router.onError (reload, or the "page load failed" message), but vue-router still rejects the push() promise, and posthog-js reports that rejection as an unhandled exception, adding noise after every deploy. posthog-js wraps window.onunhandledrejection directly and ignores defaultPrevented, so the filter lives in before_send.

Closes #554

Changes

  • add dropChunkLoadErrors before_send: drops $exception events whose entries are all chunk-load errors (reuses isChunkLoadError from chunkReload)
  • before_send is now [maskUrlCodes, dropChunkLoadErrors]
  • tests for dropped, kept (other, mixed) and non-exception events
  • docs/analytics.md notes the filter

Trade-off: a chunk that stays broken after chunkReload's reload guard is no longer reported to PostHog either (the user still sees the message), same as navigations via RouterLink already behaved.

How it was verified

  • pnpm test && pnpm test:components && pnpm tsc && pnpm lint && pnpm knip and pnpm build pass.
  • Independent code review: PASS. Checked against installed posthog-js 1.434.13 / vue-router 5.3.1 that the message lands in $exception_list[].value and that before_send arrays run in order with null short-circuiting.
  • No e2e walk: no user-visible change. Confirm in production after deploy that the PostHog issue gets no new HomepageView chunk-load samples (beyond tabs still on the pre-fix bundle).

🤖 Generated with Claude Code

After a deploy, a stale tab's programmatic router.push() to a lazy route
fails to load the removed chunk. chunkReload handles it (reload or
message), but vue-router still rejects the push and posthog-js reports
the rejection as unhandled.

- add dropChunkLoadErrors before_send: drops $exception events whose
  entries are all chunk-load errors (reuses isChunkLoadError)
- before_send is now [maskUrlCodes, dropChunkLoadErrors]
- tests for dropped, kept (other, mixed) and non-exception events
- docs/analytics.md notes the filter

Closes #554

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for prunplanner-preview ready!

Name Link
🔨 Latest commit 5decdae
🔍 Latest deploy log https://app.netlify.com/projects/prunplanner-preview/deploys/6abf573a7ed803000803a735
😎 Deploy Preview https://deploy-preview-556--prunplanner-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production

codacy-production Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage ∅ diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2dd075e) 3714 3624 97.58%
Head commit (5decdae) 3714 (+0) 3624 (+0) 97.58% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#556) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jplacht
jplacht merged commit bc2c082 into main Oct 2, 2026
11 checks passed
@jplacht
jplacht deleted the fix/chunk-load-unhandled-rejection branch October 2, 2026 07:24
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.

Chunk-load failure after a deploy escapes as an unhandled rejection

1 participant