fix(host): use session.snapshotEvents() for dsh-session >= 0.1.2-rc.1 - #7
Merged
Merged
Conversation
dsh-session removed the public \events\ property in 0.1.2-rc.1; the /usage route crashed with 'events is not iterable' (400) and the rounds chart disappeared. Prefer snapshotEvents() with a legacy fallback, and align the vendored SessionEventLike type (add time).
Max-Samson
self-requested a review
September 7, 2026 15:19
…he new API is present, added to cover the snapshotEvents() branch introduced by commit c92e3f3
Max-Samson
approved these changes
Sep 8, 2026
Max-Samson
left a comment
Owner
There was a problem hiding this comment.
@GImDX Thanks for the clean fix.
The feature detection (typeof session.snapshotEvents === 'function') and fallback to session.events ?? [] correctly handle the breaking change in dsh-session >= 0.1.2-rc.1 while preserving backwards compatibility.
I have added a dedicated unit test verifying both the snapshotEvents() preference and the fallback behavior under /usage. All 40 tests and typechecks pass.
Max-Samson
added a commit
that referenced
this pull request
Sep 8, 2026
…session >= 0.1.2-rc.1) - fix(host): adapt /usage route to use session.snapshotEvents() for dsh-session >= 0.1.2-rc.1 with fallback to legacy session.events (#7) - test: add coverage for snapshotEvents() preference and fallback under /usage - docs: update README and CHANGELOG to 1.1.4 - chore: bump version to 1.1.4 in package.json and package-lock.json
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.
Problem
dsh-session0.1.2-rc.1 removed the publiceventsproperty onSession(replaced bysnapshotEvents()). The/dsh-usage-chart/usageroute still readssession.events, which is nowundefined:foldRounds(undefined)throwsTypeError: events is not iterabledsh-host-webserverwraps the uncaught handler error as a bare400empty responseVerified against a live deployment on dsh-session 0.1.2-rc.1:
/usage?session=<loaded session>returns an empty 400,/usage?session=<unknown>returns the plugin 404 JSON, and folding the same session log offline succeeds — the crash only occurs on the new runtime API shape.Fix
session.snapshotEvents()when present, with a legacysession.eventsfallback (?? []so a missing API can never crash the route again)SessionEventLiketype intypes/cordis.d.ts(add requiredtime, markeventsoptional, addsnapshotEvents?)Verification
npm run typecheckcleannode --test tests/*.test.mjs→ 39/39 pass