feat: make bridge startup timeout and hang threshold configurable via aft.jsonc#90
feat: make bridge startup timeout and hang threshold configurable via aft.jsonc#90herjarsa wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode-plugin/src/index.ts">
<violation number="1" location="packages/opencode-plugin/src/index.ts:564">
P2: Duplicate consecutive assignments to poolOptions.timeoutMs and poolOptions.hangTimeoutThreshold</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | ||
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; | ||
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | ||
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; |
There was a problem hiding this comment.
P2: Duplicate consecutive assignments to poolOptions.timeoutMs and poolOptions.hangTimeoutThreshold
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/opencode-plugin/src/index.ts, line 564:
<comment>Duplicate consecutive assignments to poolOptions.timeoutMs and poolOptions.hangTimeoutThreshold</comment>
<file context>
@@ -561,6 +561,10 @@ async function initializePluginForDirectory(input: Parameters<Plugin>[0]) {
);
},
};
+ poolOptions.timeoutMs = aftConfig.configure_timeout_ms;
+ poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold;
+ poolOptions.timeoutMs = aftConfig.configure_timeout_ms;
</file context>
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | |
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; | |
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | |
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; | |
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | |
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; |
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | ||
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; | ||
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | ||
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; |
There was a problem hiding this comment.
The two assignment pairs at lines 564–567 are exact duplicates —
timeoutMs and hangTimeoutThreshold are each written twice with the same value. This is a copy-paste artifact; the second pair is dead code and should be removed.
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | |
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; | |
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | |
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; | |
| poolOptions.timeoutMs = aftConfig.configure_timeout_ms; | |
| poolOptions.hangTimeoutThreshold = aftConfig.hang_timeout_threshold; |
e44ef33 to
39fb77c
Compare
… aft.jsonc
WSL/DrvFs environments have slow filesystem startup (95s+ cold start),
causing the AFT bridge binary to hit the hardcoded 30s timeout and enter
a restart loop. This adds two new optional fields to aft.jsonc:
- configure_timeout_ms: bridge startup timeout (default: 30000)
- hang_timeout_threshold: consecutive timeouts before restart (default: 2)
Both can be raised in WSL environments, e.g.:
{ "configure_timeout_ms": 120000, "hang_timeout_threshold": 10 }
Changes:
- Add hangTimeoutThreshold option to BridgeOptions interface
- Store instance-level hangTimeoutThreshold in BinaryBridge (replaces const)
- Add configure_timeout_ms and hang_timeout_threshold to AftConfigSchema
- Pass config values through poolOptions to BridgePool
39fb77c to
7a175d1
Compare
|
Fixed the duplicate assignment. @cubic-dev-ai please re-review. |
1 similar comment
|
Fixed the duplicate assignment. @cubic-dev-ai please re-review. |
@herjarsa I have started the AI code review. It will take a few minutes to complete. |
1 similar comment
@herjarsa I have started the AI code review. It will take a few minutes to complete. |
Problem
WSL/DrvFs environments have slow filesystem startup (95s+ cold start measured with total 2721
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 .
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 17:02 ..
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 .alfonso
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 .bg-shell
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 .cargo
-rw-r--r-- 1 herjarsa 197121 373 Jun 3 16:27 .dockerignore
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 17:02 .git
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 .github
-rw-r--r-- 1 herjarsa 197121 2340 Jun 3 16:27 .gitignore
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 .gsd
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 .opencode
-rw-r--r-- 1 herjarsa 197121 25392 Jun 3 16:27 ARCHITECTURE.md
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 assets
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 benchmarks
-rw-r--r-- 1 herjarsa 197121 1861 Jun 3 16:27 biome.json
-rw-r--r-- 1 herjarsa 197121 87780 Jun 3 16:27 bun.lock
-rw-r--r-- 1 herjarsa 197121 98740 Jun 3 16:27 Cargo.lock
-rw-r--r-- 1 herjarsa 197121 517 Jun 3 16:27 Cargo.toml
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 crates
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 docs
-rw-r--r-- 1 herjarsa 197121 1090 Jun 3 16:27 LICENSE
-rw-r--r-- 1 herjarsa 197121 895 Jun 3 16:27 Makefile
-rw-r--r-- 1 herjarsa 197121 2306 Jun 3 16:27 package.json
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 packages
-rw-r--r-- 1 herjarsa 197121 17668 Jun 3 16:27 README.md
-rw-r--r-- 1 herjarsa 197121 110 Jun 3 16:27 rustfmt.toml
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 scripts
-rw-r--r-- 1 herjarsa 197121 15938 Jun 3 16:27 STRUCTURE.md
drwxr-xr-x 1 herjarsa 197121 0 Jun 3 16:27 tests
-rw-r--r-- 1 herjarsa 197121 386 Jun 3 16:27 tsconfig.base.json
-rw-r--r-- 1 herjarsa 197121 292 Jun 3 16:27 tsconfig.json timing). The AFT bridge binary hits the hardcoded 30s
DEFAULT_BRIDGE_TIMEOUT_MStimeout and enters a restart loop:The hardcoded
BRIDGE_HANG_TIMEOUT_THRESHOLD = 2also causes premature restarts — WSL needs more tolerance.Solution
Add two new optional fields to
aft.jsonc:configure_timeout_ms: bridge startup timeout (default: 30000)hang_timeout_threshold: consecutive timeouts before restart (default: 2)WSL config example:
{ "configure_timeout_ms": 120000, "hang_timeout_threshold": 10 }Changes
packages/aft-bridge/src/bridge.tshangTimeoutThreshold?: numbertoBridgeOptionsinterfacethis.hangTimeoutThresholdinBinaryBridgeconstructorthis.hangTimeoutThresholdinstead ofBRIDGE_HANG_TIMEOUT_THRESHOLDconstant in keepWarm logicpackages/opencode-plugin/src/config.tsconfigure_timeout_msandhang_timeout_thresholdtoAftConfigSchemapackages/opencode-plugin/src/index.tsaftConfig.configure_timeout_msandaftConfig.hang_timeout_thresholdthrough poolOptions to BridgePoolBackward Compatible
Both fields are optional with safe defaults. Existing
aft.jsoncfiles work unchanged.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Make the bridge startup timeout and hang restart threshold configurable via
aft.jsoncto prevent restart loops on slow filesystems (e.g., WSL/DrvFs). Defaults are unchanged, so no config changes are required.configure_timeout_msto control bridge timeout (default: 30000 ms).hang_timeout_thresholdfor consecutive timeouts before restart (default: 2). Values are read fromaft.jsoncand passed through the plugin to the bridge.Written for commit 7a175d1. Summary will update on new commits.
Greptile Summary
This PR makes the bridge startup timeout and hang-restart threshold configurable via
aft.jsoncto address restart loops on slow filesystems like WSL/DrvFs. Both new fields are optional with unchanged defaults, so existing configs continue to work without modification.bridge.ts: AddshangTimeoutThresholdtoBridgeOptionsand stores it as an instance field onBinaryBridge, replacing the hardcoded constant in the keep-warm logic.config.ts: ExtendsAftConfigSchemawithconfigure_timeout_msandhang_timeout_thresholdas optional positive integers.index.ts: Wires the new config fields intopoolOptions, though the two assignments are duplicated verbatim (copy-paste artifact on lines 564–567).Confidence Score: 4/5
Safe to merge — the logic change is correct and backward-compatible; only a duplicate assignment pair needs cleanup.
The bridge.ts and config.ts changes are clean. The only real flaw is a copy-paste duplication in index.ts that repeats both poolOptions assignments verbatim; it has no behavioral effect but is dead code that should be removed before merging.
packages/opencode-plugin/src/index.ts — duplicate assignment pair on lines 564–567.
Important Files Changed
hangTimeoutThresholdtoBridgeOptionsand stores it as an instance field inBinaryBridge; the constantBRIDGE_HANG_TIMEOUT_THRESHOLDis replaced by the instance value in keep-warm logic. Clean implementation.configure_timeout_msandhang_timeout_thresholdas optional positive integers toAftConfigSchema. Schema additions are correct and backward-compatible.poolOptions, but the two assignments are copy-pasted twice (lines 564–567), resulting in redundant dead code.Sequence Diagram
sequenceDiagram participant Config as aft.jsonc participant Plugin as opencode-plugin/index.ts participant Pool as BridgePool participant Bridge as BinaryBridge Config->>Plugin: configure_timeout_ms, hang_timeout_threshold Plugin->>Pool: poolOptions.timeoutMs, poolOptions.hangTimeoutThreshold Pool->>Bridge: new BinaryBridge(options) Bridge->>Bridge: "this.timeoutMs = options.timeoutMs ?? DEFAULT_BRIDGE_TIMEOUT_MS" Bridge->>Bridge: "this.hangTimeoutThreshold = options.hangTimeoutThreshold ?? BRIDGE_HANG_TIMEOUT_THRESHOLD" Note over Bridge: On request timeout Bridge->>Bridge: consecutiveTimeouts++ alt "consecutiveTimeouts < this.hangTimeoutThreshold OR childActiveSinceRequest" Bridge->>Bridge: Keep warm (no restart) else Bridge->>Bridge: Restart bridge endReviews (1): Last reviewed commit: "feat: make bridge startup timeout and ha..." | Re-trigger Greptile