Skip to content

feat: add targeted session logging to diagnose content-loss#147

Merged
kptdobe merged 2 commits into
mainfrom
feature/better-session-logs
May 13, 2026
Merged

feat: add targeted session logging to diagnose content-loss#147
kptdobe merged 2 commits into
mainfrom
feature/better-session-logs

Conversation

@kptdobe
Copy link
Copy Markdown
Contributor

@kptdobe kptdobe commented May 13, 2026

Summary

  • Logs session duration and unsaved state when the last WebSocket connection closes: [docroom] Last connection closed <url> duration: <N>ms unsaved: true|false
  • Logs when a save to da-admin succeeds: [docroom] Saved to da-admin <url> <N>b
  • Logs when a concurrent save is already in progress (the saving guard fires): [docroom] Skip save: concurrent save in progress <url>
  • Resets hasClientChanged to false after each successful save, so the unsaved flag at close time reflects the state since the last save — not the entire session lifetime
  • Reuses hasClientChanged (introduced in fix: guard persistence.put against empty-stub overwrites (COR-31) #142) rather than adding a new flag

These logs directly address the gap identified in issue #145: session durations were not visible in Coralogix worker traces, making it impossible to correlate session cancellations with missed saves.

Test plan

  • npm test — 103 tests pass, 100% coverage
  • npm run lint — 0 errors
  • New tests: conn.connectedAt set on connection, closeConn logs duration + unsaved: false/true, persistence.update logs save success, debounced save logs concurrent-skip

🤖 Generated with Claude Code

kptdobe and others added 2 commits May 13, 2026 09:53
Track conn.connectedAt on setup, log last-connection-close with duration
and unsaved state, log successful saves to da-admin, set ydoc.isDirty on
updates, clear it after a successful debounced save, and log when a
concurrent-save guard skips a save.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use the existing hasClientChanged flag (from #142) to track unsaved
state at last-connection-close, resetting it to false after each
successful da-admin save. Removes the redundant isDirty flag.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kptdobe kptdobe requested a review from bosschaert May 13, 2026 08:46
@kptdobe kptdobe merged commit f96ce19 into main May 13, 2026
5 checks passed
@kptdobe kptdobe deleted the feature/better-session-logs branch May 13, 2026 09:47
adobe-bot pushed a commit that referenced this pull request May 13, 2026
# [1.3.0](v1.2.7...v1.3.0) (2026-05-13)

### Features

* add targeted session logging to diagnose content-loss ([#147](#147)) ([f96ce19](f96ce19))
@adobe-bot
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants