Repository navigation
test(sdk-next): make embedded host isolation test deterministic - #14161
Merged
Merged
Conversation
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (1 file)
Fix these issues in Kilo Cloud Reviewed by deepseek-v4.1-flash · Input: 47.6K · Output: 6.8K · Cached: 303K Review guidance: REVIEW.md from base branch |
marius-kilocode
enabled auto-merge
September 15, 2026 10:21
iscekic
approved these changes
Sep 15, 2026
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.
What Problem This Solves
independent embedded hosts do not share live notificationsinpackages/sdk-next/test/embedded.test.tscan hang until its hardcoded 10 second budget and fail. The test creates twoOpenCode.create()hosts against one temporary SQLite database, subscribes to both event streams, and waits for bothserver.connectedlatches.Root Cause
OpenCode.create()builds its server layer lazily on the first request. Subscribing both hosts at the same time therefore triggers two concurrent lazy layer builds against the same database.Building
Credential.noderunslegacyImportLayer(packages/core/src/credential.ts:110). When a legacyaccount.jsonexists, it reads thedata_migrationjournal, finds no row forcredential.kilo-account-json-v3, and inserts one inside a transaction (credential.ts:159). That insert has no conflict handling. Both hosts pass the existence check before either inserts, so the second insert violates thedata_migration.nameprimary key. That host's request fails, itsserver.connectednever arrives, and the test waits onEffect.all([firstReady.await, secondReady.await]), which has no timeout, until the 10 second test budget expires.Local reproduction before the fix (macOS, developer profile with
account.json):With a clean
XDG_DATA_HOME(noaccount.json) the same test passes in about 1.2 to 1.8 seconds, which confirms the legacy credential import is the trigger.Why This Change Was Made
The test's intent, that two independent hosts do not share live notifications, does not require the two hosts to run their first lazy layer build concurrently. Serializing the host startup removes the race without changing the assertion:
server.connected;server.connected;The second host's subscription is still active before the event is emitted, so the isolation check is unchanged. The fix is test-side only;
credential.tsis left untouched.User Impact
None. Test-only change, so no changeset is needed.
Evidence
test/embedded.test.tspass 6/6, about 2.3 to 2.8 seconds.KILO_EXPERIMENTAL_DISABLE_FILEWATCHER=true, cleanXDG_DATA_HOME): full file pass 5/5, about 3.1 to 4.8 seconds.bun run test:cifrompackages/sdk-next: 5 pass, 0 fail.bun run typecheckfrompackages/sdk-next: clean (tsgo --noEmit).bun run lintfrom the repo root: 0 errors.Note on the reported CI failure
The macOS job cited when this work started (
unit (macos), run 34954357833, job 104332897237) failedRun non-CLI unit testson@opencode-ai/tui#test:ci(test/cli/tui/diff-viewer-file-tree.test.tsx), not on sdk-next. Theunit-macos-1-1JUnit artifact for that run recordsindependent embedded hosts do not share live notificationsas passing in 0.805s. So this sdk-next test was not the blocker in that job. This change fixes a separate deterministic failure that reproduces on developer machines with legacy credential state, and the latent concurrent startup race behind it.