fix: decouple slow services from InstanceBootstrap critical path#23408
Open
codeg-dev wants to merge 8 commits intoanomalyco:devfrom
Open
fix: decouple slow services from InstanceBootstrap critical path#23408codeg-dev wants to merge 8 commits intoanomalyco:devfrom
codeg-dev wants to merge 8 commits intoanomalyco:devfrom
Conversation
Contributor
|
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. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Fall back to a deterministic path-based project ID when rev-list stalls so external-volume project open can recover without freezing the UI.
FileWatcher.init() blocks on parcel-watcher subscribe which can take several seconds on external volumes (e.g. /Volumes/*). With the previous forkDetach approach, the child fiber blocked internally but Effect's scheduler only ran it after the parent completed, meaning the parent InstanceBootstrap was also delayed. Fix: explicitly split InstanceBootstrap services into two groups: - fastGroup (LSP, Format, File, Snapshot, ShareNext): awaited with concurrency=unbounded so handlers can safely use these services. - deferredGroup (FileWatcher, Vcs): launched via forkDaemon so their blocking init() (subscribe, git branch/defaultBranch) runs in a daemon fiber and does not delay the HTTP response. Closes: related to hanging on slow external-volume project open
…tests - Replace forkDaemon/catchAllCause with forkDetach/catchCause to match Effect 4.0.0-beta.48's actual exported API (the patched local package does not export forkDaemon or catchAllCause). - Add packages/opencode/test/project/bootstrap.test.ts with 5 tests: 1. forkDetach does not block parent gen completion (< 500ms assertion) 2. detached fiber failure does not propagate to parent 3. concurrent init calls are guarded (init count == 1) 4. bootstrap returns < 500ms with 2-second slow mock watcher 5. bootstrap succeeds even when deferred service init throws
- Replace .map() over service union array with explicit Effect.all([...]) calls for each service; union-typed .map() loses R/E type info and breaks callers that expect the typed AppLayer requirements (TS2345 on Effect<void, unknown, unknown> vs Effect<void, unknown, AppLayer>). - Explicit forkDetach per service preserves the per-service R type correctly. - Remove unused Cause import. - Fix test mock: cast Effect.fail result to Effect<void> for the mock interface.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
6a6fe6d to
70ebe33
Compare
Author
|
Rebased onto |
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 #23409
Type of change
What does this PR do?
This fixes slow cold project opens on external macOS volumes by removing two long-running operations from the request path.
rev-listtimeout fallback so project ID discovery no longer stalls for several secondsInstanceBootstrapon a fast path by awaiting only fast services and detachingFileWatcher/Vcsinit workOn my external-volume repro path, the first cold request dropped from about 6.3s to about 580ms.
How did you verify your code works?
packages/opencode/test/project/bootstrap.test.tsfor the detached bootstrap behaviorproject,watcher, andbootstrappackages/opencodetest suite; remaining failures were pre-existing and unrelated/Volumes/DATA/github/TokenMeterScreenshots / recordings
Not a UI change.
Checklist