Fix #1747: bridge.cts 启动竞态: startStdioServer 应在 core.init 之前启动#2046
Merged
syzsunshine219 merged 1 commit intoJul 2, 2026
Merged
Conversation
…ering (MemTensor#1747) Add regression coverage for MemTensor#1747: the Hermes stdio bridge must call startStdioServer() BEFORE awaiting core.init(). Otherwise orphan-episode recovery (LLM-heavy, 10-60+s) inside init() blocks the stdio read loop, and the Python adapter times out on the first session.open RPC. The structural fix already shipped in 7c6bd25 (May 2026). This test prevents the ordering from being silently reversed by a future refactor: * startStdioServer returns before core.init() resolves * core.init() runs concurrently with stdio (stdio available within ms, not after the init-block delay) Uses a stub MemoryCore with a delayed init to simulate orphan recovery. Full bridge suite: 17/17 tests pass. Type-check clean. Closes MemTensor#1747
Collaborator
Author
🤖 Open Code ReviewTarget: PR #2046 ✅ OpenCodeReview: No supported files changed. Generated by cloud-assistant via Open Code Review. |
Collaborator
Author
✅ Automated Test Results: PASSEDAll tests passed (2/2 executed). memos_local_plugin/unit: 2/2. Duration: 3s Branch: |
Collaborator
Author
Automated Test Results: PASSEDCloud test-engine run
This PR has cloud test coverage for the changed plugin scope. Manual review is still required before merge. |
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.
Description
Investigation for issue #1747 found the requested structural fix — moving
startStdioServer({ core })beforeawait core.init()inapps/memos-local-plugin/bridge.cts— already landed on the base branchdev-20260624-v2.0.22via commit7c6bd250(May 2026). The current bridge.cts starts the stdio server at line 328 and only awaits core.init() at line 338, so the reported orphan-episode startup race is no longer reproducible.To prevent a future refactor from silently reversing that ordering, this branch adds a regression test at
apps/memos-local-plugin/tests/unit/bridge/startup-order.test.tswith two vitest cases: (1)startStdioServerreturns beforecore.init()resolves, using a stubMemoryCorewhoseinit()blocks 50 ms to simulate orphan recovery, and (2)core.init()runs concurrently with stdio startup — measured wall-clock time confirms stdio is available in ≪ init-delay ms. Negative verification: reversing the order in a scratch script trips the first assertion as expected.Full bridge unit suite passes:
tests/unit/bridge/stdio.test.ts(5),methods.test.ts(10), and the newstartup-order.test.ts(2) — 17/17 tests green.tsc --noEmitis clean. No lockfile or source changes were made. Suggested follow-ups from the issue (removing the deadCORE_INITRPC method; adding aserver.readysignal) are deliberately out of scope and can be filed as separate tickets.Task file archived to
memos-autodev-specsmain branch at commitd4525a4. Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller.Related Issue (Required): Fixes #1747
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller please review this PR.
Reviewer Checklist