Skip to content

fix(meditations): harden frame publish cache writes - #399

Merged
Ardnived merged 2 commits into
mainfrom
fix/issue-390-meditation-publish-500
May 25, 2026
Merged

Ardnived merged 2 commits into
mainfrom
fix/issue-390-meditation-publish-500

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

  • normalize meditation frames before save/read and drop malformed entries with issue-390 diagnostics
  • invalidate and recompute subtleSystemNodeWeights from the full frame timeline
  • persist derived cache updates with low-level DB writes so cache failures do not 500 publishes

Tests

  • pnpm test:int tests/int/meditationFrames.int.spec.ts tests/int/meditation-lectures.int.spec.ts
  • pnpm lint

Notes

  • Broader pnpm test:int still has unrelated existing/environment failures: translation global assertions, suite timeouts, and Wrangler EPERM bind/logging issues.

Ardnived and others added 2 commits May 25, 2026 15:12
…lpers

Self-review pass on the issue-390 frame hardening:

- Add module JSDoc to src/lib/meditations/frames.ts and a rationale
  comment on persistMeditationNodeWeightsCache explaining why it goes
  through payload.db.updateOne (break recompute loop + best-effort).
- Replace the untyped `(options as { previousValue?: unknown })` cast
  with direct access — Payload v3 exposes previousValue on
  BaseValidateOptions.
- Drop the eager JSON.stringify in normalizeMeditationFrames; compute
  normalizedPayloadBytes lazily inside getFrameDiagnosticsLogContext
  where it's actually read. Replace JSON.stringify equality in
  meditationFramesChanged with a length+per-index loop (called from
  both invalidate + recompute hooks on every save).
- Refactor the cache-failure test to use vi.spyOn / mockRestore so a
  thrown assertion can't leak the patched db.updateOne to siblings.

No behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit b69d351 into main May 25, 2026
@Ardnived
Ardnived deleted the fix/issue-390-meditation-publish-500 branch May 25, 2026 07:55
Ardnived added a commit that referenced this pull request Nov 5, 2026
Adds operation, documentId, request body (truncated to 10KB), and an
`issue: '390'` tag for meditations errors to the global Sentry afterError
context. PR #399 already silenced the cache-write path, but the same 500
keeps reproducing on first-publish of a newly-created meditation — and the
existing context (collection, locale, url) isn't enough to tell which of
the four suspect paths threw. This lifts visibility so the next occurrence
is diagnosable from the Sentry dashboard alone.

Diagnostic-only — no speculative fixes to the suspect paths yet.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
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.

1 participant