Repository navigation
test(main): fail if the journal's shared no-row error returns (follow-up to #27342) - #27375
Conversation
Follow-up to #27342: the existing tests also pass on the old module-level Error, so add one that fails if a single error object is reused.
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The new regression test can pass without observing both expected enqueue errors, weakening its protection against that behavior regressing. The needed test fix is small, and the concern is bounded. Pre-merge checks |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/native-chat/agent-session-journal/journal-item-appender.test.ts (1)
27-27: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert that both enqueue callbacks threw.
The fake
enqueuerecords one error for each null resolution. The uniqueness assertion also passes whenthrownis empty or contains only one error. Assert the expected count first.Suggested assertion
+ expect(thrown).toHaveLength(2) expect(new Set(thrown).size).toBe(thrown.length)
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
66af8e11-d7cd-45f7-afb9-2bd74807512a
📒 Files selected for processing (1)
src/main/native-chat/agent-session-journal/journal-item-appender.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
ELI5
#27342 fixed a small memory retention in the agent journal, but its tests would still pass if the old code came back. This adds one test that fails on the old code.
What Changed
Adds
journal-item-appender.test.ts. It runs two "resolver found nothing" appends throughJournalItemAppenderwith a fake queue that records any error thrown inside the queued work. It asserts both appends still return null and that no single error object is thrown twice.No production code changes, and nothing changes for users.
Why
Before #27342, one
Errorwas created when the module loaded and thrown on every no-result append. That single object's stack kept startup code and the bundle-read buffer alive. #27342's two tests check behavior (null result, other errors propagate), which the old code also satisfied. A shared, reused error object is the only observable sign of the old pattern, so the test checks for exactly that.Alternatives considered: counting
Errorconstruction during module load would mean replacing the globalErrorand depending on how the test runner evaluates modules, which is brittle. Inspecting stack contents depends on V8 and bundler frame layout. The identity check needs neither. It also stays green if a future change stops using a thrown error entirely: with nothing thrown, the check passes trivially.Linked Issue
No linked issue. Follow-up to #27342.
Visual Proof
N/A: test-only change with no UI or behavior change.
Testing
New test passes on
main, alongside the existingjournal-write-queue.test.tssuite (12 tests across 2 files).With
journal-item-appender.tstemporarily restored to the pre-perf(main): release startup allocations held by journal sentinel #27342 version (bc02f3ce6ea^), the new test fails: the distinct-object count was 1 where 2 was expected, because the same error object was thrown both times. I then restored the file.oxlint,oxfmt --check, and the lint-staged pre-commit tasks are clean on the new file.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
The single new test file is the whole change.
Agent skill upstream boundary
Notes
Test-only and platform-independent. No effect on SSH, mobile, wire compatibility, or performance.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)