Skip to content

šŸ› Stop a recovered chapter jump reporting as a reader error - #1600

Open
williamchong wants to merge 1 commit into
likecoin:developfrom
williamchong:feature/epub
Open

šŸ› Stop a recovered chapter jump reporting as a reader error#1600
williamchong wants to merge 1 commit into
likecoin:developfrom
williamchong:feature/epub

Conversation

@williamchong

Copy link
Copy Markdown
Member

A ToC href and the spine's can name one file by different paths, so the first display attempt missed and setActiveNavItem recovered on the basename map. That miss still logged at error level, which Sentry's captureConsoleIntegration and PostHog's capture_console_errors both promote into an exception: ~100/day across 160 users, none of whom saw anything go wrong, escalating over the real reader errors.

Resolve the spine href before the first attempt so the jump lands outright, and warn rather than error whenever the caller holds a fallback. reader_epub_display_failed stays the measurement, now with its rung passed explicitly instead of always reporting attempt zero.

A ToC href and the spine's can name one file by different paths, so the
first display attempt missed and `setActiveNavItem` recovered on the
basename map. That miss still logged at error level, which Sentry's
captureConsoleIntegration and PostHog's capture_console_errors both
promote into an exception: ~100/day across 160 users, none of whom saw
anything go wrong, escalating over the real reader errors.

Resolve the spine href before the first attempt so the jump lands
outright, and warn rather than error whenever the caller holds a
fallback. `reader_epub_display_failed` stays the measurement, now with
its rung passed explicitly instead of always reporting attempt zero.
@williamchong
williamchong requested review from a team and nwingt and a lite review from Copilot September 4, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟔 Changes recommended

The new ā€œwarn vs errorā€ behavior is keyed to isSilentError, which is also used for UI suppression, and can unintentionally hide genuine user-visible navigation failures from Sentry/PostHog.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR reduces false-positive ā€œreader errorā€ exceptions caused by EPUB ToC targets that don’t match the spine’s canonical href path. It makes chapter jumps land on the correct spine href on the first attempt (instead of failing then recovering), and adjusts failure logging so recovered attempts don’t get promoted into Sentry/PostHog exceptions while still emitting the reader_epub_display_failed metric with an explicit fallback rung.

Changes:

  • Downgrade console logging to warn for ā€œsilentā€ display failures to avoid recovered failures being captured as exceptions.
  • Resolve the spine href up-front in setActiveNavItem (using isEPUBTargetInSpine) so mismatched ToC/spine paths display correctly on the first attempt.
  • Pass explicit attempt values into displayRendition so reader_epub_display_failed can distinguish which fallback rung failed.
File summaries
File Description
app/pages/reader/epub.vue Improves EPUB chapter jump targeting and adjusts logging/analytics around display failures to reduce noisy exceptions.
Review details

Suppressed comments (1)

app/pages/reader/epub.vue:1776

  • The first displayRendition(primaryHref, { isSilentError: true, ... }) attempt is always marked silent. After the log-level change in handleDisplayFailure, any failure on this first attempt will be logged as warn even when there is no subsequent fallback display attempt (e.g. spineHref is missing or primaryHref already equals spineHref), which can hide genuine user-facing navigation failures from Sentry/PostHog.

It would be safer if the ā€œdowngrade to warnā€ decision was based on whether a second display attempt exists (or another concrete recovery path), rather than on isSilentError.

  const isNavHrefInSpine = isEPUBTargetInSpine(rendition.value?.book?.spine, item.href)
  const primaryHref = isNavHrefInSpine || !spineHref ? item.href : spineHref

  let hasDisplayed = await displayRendition(primaryHref, { isSilentError: true, attempt: 0 })
  if (hasDisplayed) return true
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

šŸ’” Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/pages/reader/epub.vue
Comment on lines +1077 to +1080
// A silent failure means the caller has a fallback, so warn: Sentry and
// PostHog both promote console.error into an exception, and a recovered
// rung would report as a user-facing break.
console[isSilentError ? 'warn' : 'error'](`Error occurred when displaying${target ? ` ${target}` : ''} in rendition of ${nftClassId.value}`, error)
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