test(core): await debounced sessions.json flush in plan-store test#90
Merged
deepagent-ai merged 1 commit intoJul 24, 2026
Merged
Conversation
saveToDisk() became setImmediate-debounced in c0b7997, but the I33-1 plan-store test still read sessions.json synchronously right after SessionState.setPlan, racing the deferred flush and failing with ENOENT (observed as the unit (macos) CI failure on deepagent-ltd#89). Yield one event-loop turn before the assertion so flushToDisk lands the file first. Signed-off-by: thomas-yanga <odie_majere@outlook.com>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
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.
Issue for this PR
Closes #
(no tracking issue — this fixes the
unit (macos)CI failure seen on #89)Type of change
What does this PR do?
c0b79979("perf(core): 修复启动慢根因 — sessions.json 防抖") changedsession-state.tssaveToDisk()from a synchronous write to a debouncedsetImmediate(flushToDisk). The I33-1 plan-store test (packages/core/test/deepagent/plan-store.test.ts) predates that change and still assumed synchronouspersistence:
The test body is fully synchronous, so whether the file exists at read time depends on event-loop timing — on the macOS runner it consistently fails with
ENOENT, which is what failed unit (macos) (@deepagent-code/core#test:ci exit 1) on #89. The linux/windows jobs in that run were cancelled (fail-fast) before
executing, so this is not actually macOS-specific.
Fix: make the test async and yield one event-loop turn (await new Promise((resolve) => setImmediate(resolve))) after setPlan, so the debounced flushToDisk lands
sessions.json before the assertion reads it. No production code changes. I also replaced the inline require("node:fs").readFileSync with the top-level
readFileSync import.
I verified the root cause by checking out c0b7997^ in a worktree: the test passes there and fails at dev HEAD, so the debounce commit is what broke it.
How did you verify your code works?
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
N/A — test-only change.
Checklist