Skip to content

🔇 Discard expected navigator.locks errors from page teardown - #4691

Merged
thomas-lebeau merged 2 commits into
mainfrom
thomas.lebeau/session-lock-cleanup
May 28, 2026
Merged

🔇 Discard expected navigator.locks errors from page teardown#4691
thomas-lebeau merged 2 commits into
mainfrom
thomas.lebeau/session-lock-cleanup

Conversation

@thomas-lebeau

@thomas-lebeau thomas-lebeau commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Motivation

In-flight navigator.locks.request callbacks reject when the browsing context is torn down. These rejections aren't actionable — the page is going away — but they were being forwarded to telemetry as errors, generating noise. The investigation telemetry added in #4668 confirmed the cause; this PR acts on those findings.

Changes

  • sessionInCookie.ts: catch and discard the two error shapes seen in the wild:

    • WebKit: AbortError: Promise was rejected because the browsing context is going away
    • Chromium: Error: Failed to execute 'request' on 'LockManager': The provided callback is no longer runnable.

    All other lock rejections still propagate.

  • Remove the addTelemetryError call on lock-request failures along with the supporting helpers that only existed to enrich its context: buildLockErrorContext, queryLockSnapshot, getNavigationType, isInIframe, the LockQuerySnapshot interface, the LOCK_QUERY_TIMEOUT constant, and the initTimestamp / lockRequestedAt bookkeeping.

  • Delete the lifecycleTracker module (lifecycleTracker.ts + spec). Its only consumer was buildLockErrorContext; with that gone, startLifecycleTracker was registering capture-phase listeners on pageshow / pagehide / visibilitychange / freeze / resume / beforeunload / prerenderingchange only to record state nobody read. The startLifecycleTracker(configuration) and resetLifecycleTracker() calls in sessionManager.ts (and the corresponding test cleanup) are dropped.

Test instructions

  • yarn typecheck and yarn lint pass.
  • yarn test:unit --spec packages/core/src/domain/session/storeStrategies/sessionInCookie.spec.ts
  • yarn test:unit --spec packages/core/src/domain/session/sessionManager.spec.ts
  • After deploy, the session-lock-error telemetry monitors should stop firing for the two known teardown signatures while still capturing any genuinely unexpected lock failures.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented May 28, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 0.00%
Overall Coverage: 76.72% (+0.15%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: cb5873a | Docs | Datadog PR Page | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented May 28, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 175.26 KiB 173.69 KiB -1.57 KiB -0.89%
Rum Profiler 8.08 KiB 8.08 KiB 0 B 0.00%
Rum Recorder 21.23 KiB 21.23 KiB 0 B 0.00%
Logs 56.96 KiB 55.47 KiB -1.49 KiB -2.62%
Rum Slim 132.88 KiB 131.39 KiB -1.49 KiB -1.12%
Worker 22.99 KiB 22.99 KiB 0 B 0.00%

🔗 RealWorld

@thomas-lebeau
thomas-lebeau marked this pull request as ready for review May 28, 2026 08:58
@thomas-lebeau
thomas-lebeau requested a review from a team as a code owner May 28, 2026 08:58
When a tab is being torn down (pagehide, print dialog, bfcache), in-flight
`navigator.locks.request` callbacks reject with errors that simply mean the
browsing context is going away — there is nothing actionable to do. They
surface in different shapes across browsers:

  - DOMException "AbortError: ... browsing context is going away"
  - Error "Failed to execute '...' on 'LockManager': The provided callback
    is no longer runnable."

Now that we know what these errors are (after the investigation telemetry
added in #4668), drop them on the floor instead of forwarding to telemetry.

This also removes the supporting machinery that only existed to enrich the
telemetry context: `buildLockErrorContext`, `queryLockSnapshot`, and the
entire `lifecycleTracker` module — whose only consumer was the lock error
telemetry.
Pairs with 🔊 (logging) — for commits that remove debug logs or
telemetry rather than adding them.
@thomas-lebeau
thomas-lebeau force-pushed the thomas.lebeau/session-lock-cleanup branch from 902e710 to cb5873a Compare May 28, 2026 10:42
@thomas-lebeau
thomas-lebeau merged commit 06e7cb4 into main May 28, 2026
30 checks passed
@thomas-lebeau
thomas-lebeau deleted the thomas.lebeau/session-lock-cleanup branch May 28, 2026 11:48
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants