Fix adobe-edge web: "Session ID is not available" race on media events - #460
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 8b556cb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
tvanlaerhoven
force-pushed
the
bugfix/adobe-edge-session-start-race
branch
from
August 13, 2026 21:11
008cf72 to
cbcc31c
Compare
The web handler marked the media session as started immediately after calling trackSessionStart(), without awaiting the returned promise. If the edge network response contained no session ID (e.g. transient edge failure), every subsequent media event rejected with "Session ID is not available for playerId" for the remainder of the session, surfacing as unhandled promise rejections. - Only mark the session in progress after trackSessionStart() resolves with a sessionId; queue events in the meantime. - Retry failed session starts with exponential backoff (3 attempts). - Catch tracker promise rejections and log them in debug mode. - Close sessions that get confirmed after a sourcechange already ended them. - Also start the session when loadedmetadata fired before the getMediaAnalyticsTracker promise resolved, which previously dropped the whole session silently. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The changelog is generated from changesets at release time (changeset:version); the previous commit edited CHANGELOG.md directly. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…onfirmed sessions Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
tvanlaerhoven
force-pushed
the
bugfix/adobe-edge-session-start-race
branch
from
August 14, 2026 00:27
cbb14a6 to
9ff1ccc
Compare
A session whose start is confirmed after it was superseded by a new source is now completed and ended on its own tracker, so it is no longer left open on the edge network. Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
…atched Alloy builds a media event's payload from the tracker state in a microtask after the event was triggered, so destroying the tracker right after trackComplete/trackSessionEnd would drop the beacon. Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
…n per session - A synchronous failure of getInstance/trackSessionStart no longer leaves the handler stuck in 'starting'; it is retried like an async failure. - The pending completion is tied to the session generation, so a session that was superseded by a source change is not reported as completed. Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On web,
AdobeEdgeHandlertreatedtrackSessionStart()as fire-and-forget: it flipped_sessionInProgress = trueimmediately, so any media event fired before the edge network returned asessionIdwas rejected by alloy withFailed to trigger media event: media.bitrateChange. Session ID is not available for playerId: <uuid>.The session is now only considered active once the start is confirmed, events are queued until then, and failed starts are retried:
Other behaviour worth calling out:
maybeStartSession()is retried once the media tracker promise resolves, so aloadedmetadatathat arrives before the tracker is ready no longer silently skips the session start._sessionStartAbandonedis set and events are dropped (not queued) until asourcechange/stopAndStartNewSessionstarts a fresh session.updateMetadata()is snapshotted for the first attempt and reused by every retry, so a retried session start still reports the customer's metadata instead of an empty object. Metadata set after the snapshot is kept for the next session._completeOnConfirmremembers it so the late-confirmed session is completed (sessionComplete) before it is ended, instead of losing the completion.MAX_EVENT_QUEUE_SIZE = 500(oldest dropped first), so a start that never resolves cannot grow the queue without bound.Testing
In
adobe-edge:npm test(18 tests, newsessionStart.test.tscovers queue/flush, retry + recovery, rejection, tracker-not-ready race, metadata on retries, late completion, queue cap and orphan close),npm run typescript,npm run build.Link to Devin session: https://dolby.devinenterprise.com/sessions/37fdbe28150a45588efc33754efcdd32
Requested by: @tvanlaerhoven