cloudaxe-opencode/packages/opencode/test
Kit Langton 69f7182f05 fix: bound LSP diagnostic enrichment in write/edit/apply_patch (#22872)
Issue #22872 reports the write tool hanging indefinitely after a file
is written. Two underlying causes, both in the post-write LSP
enrichment path:

1. LSPClient.create wraps the `initialize` request in a 45s
   withTimeout. If the spawned LSP process is wedged (happens with
   pyright under certain conditions), every write that matches that
   LSP blocks the tool for up to 45s even though the file is on disk.

2. Server.spawn for npm-distributed LSPs (pyright, tsserver,
   biome, ...) calls Npm.which, which internally uses arborist.reify
   with no timeout. In sandboxed containers with no network access
   this promise never resolves — the write tool hangs forever.

Fix applied at three layers of defense:

- write.ts / edit.ts / apply_patch.ts: wrap the touchFile +
  diagnostics tail in a 5s Effect.timeout with catch-to-empty.
  Diagnostics are a best-effort enrichment; they must not block the
  tool's return after the file is already written.
- lsp.ts schedule(): bound server.spawn with a 10s Promise.race
  timeout. On timeout the server is added to s.broken so subsequent
  touches short-circuit instantly instead of re-racing.
- client.ts: lower the `initialize` withTimeout from 45_000 to
  10_000. If a server hasn't responded to initialize in 10s it's
  wedged; 45s was punishing for no benefit.

Reproducer tests (added in earlier commits on this branch) now pass:
- write-lsp-hang.test.ts  (branch A, 45s initialize timeout)
- write-lsp-spawn-hang.test.ts  (branch B, forever Npm.which)
Both complete in ~5s.

Full opencode test suite: 1934 pass, 0 fail.
2026-04-16 17:36:04 -04:00
..
account feat: unwrap storage namespaces to flat exports + barrel (#22747) 2026-04-15 23:30:49 -04:00
acp fix: clean up final 16 no-unused-vars warnings (#22751) 2026-04-16 03:54:21 +00:00
agent feat: unwrap tool namespaces to flat exports + barrel (#22762) 2026-04-16 03:56:54 +00:00
auth refactor(auth): remove async auth facade exports (#22306) 2026-04-13 12:31:43 -04:00
bus refactor(auth): remove async auth facade exports (#22306) 2026-04-13 12:31:43 -04:00
cli fix(test): make plugin loader theme source path separator-safe (#22870) 2026-04-16 14:45:17 -04:00
config core: modularize config parsing to improve maintainability 2026-04-16 13:29:03 -04:00
control-plane feat(core): expose workspace adaptors to plugins (#21927) 2026-04-13 13:33:13 -04:00
effect fix: clean up final 16 no-unused-vars warnings (#22751) 2026-04-16 03:54:21 +00:00
fake feat: unwrap Provider namespace + improved automation script (#22690) 2026-04-15 21:44:46 -04:00
file CLI perf: reduce deps (#22652) 2026-04-16 02:03:03 -04:00
filesystem shared package (#22626) 2026-04-15 14:26:20 +00:00
fixture test: add reproducer for write tool hanging on slow LSP initialize (#22872) 2026-04-16 15:50:06 -04:00
format tweak: make it so disabling uv or ruff fmters disables both (#21921) 2026-04-10 13:30:30 -05:00
git feat: restore git-backed review modes (#20845) 2026-04-03 09:54:57 -05:00
ide fix(test): replace structuredClone with spread for process.env (#14908) 2026-02-24 23:16:24 +10:00
installation refactor(effect): upgrade opencode to beta.46 context APIs (#21977) 2026-04-10 23:06:28 -04:00
lib fix: delete 9 dead functions with zero callers (#22697) 2026-04-16 02:01:02 +00:00
lsp feat: unwrap lsp namespaces to flat exports + barrel (#22748) 2026-04-15 23:30:52 -04:00
mcp fix: clean up final 16 no-unused-vars warnings (#22751) 2026-04-16 03:54:21 +00:00
memory feat: enable type-aware no-floating-promises rule, fix all 177 violations (#22741) 2026-04-15 23:27:32 -04:00
patch big format 2025-11-06 13:03:12 -05:00
permission feat: enable type-aware no-floating-promises rule, fix all 177 violations (#22741) 2026-04-15 23:27:32 -04:00
plugin feat: unwrap provider namespaces to flat exports + barrel (#22760) 2026-04-16 05:02:50 +00:00
project feat: unwrap storage namespaces to flat exports + barrel (#22747) 2026-04-15 23:30:49 -04:00
provider tweak: set display 'summarized' by default for opus 4.7 thorugh messages api (#22873) 2026-04-16 14:12:43 -05:00
pty refactor(pty): remove async facade exports (#22305) 2026-04-13 11:47:05 -04:00
question add experimental question HttpApi slice (#22357) 2026-04-14 19:43:49 +00:00
server feat: unwrap project namespaces to flat exports + barrel (#22743) 2026-04-15 23:28:46 -04:00
session feat: unwrap provider namespaces to flat exports + barrel (#22760) 2026-04-16 05:02:50 +00:00
share feat: unwrap storage namespaces to flat exports + barrel (#22747) 2026-04-15 23:30:49 -04:00
shell feat: unwrap 11 util namespaces to flat exports + barrel (#22739) 2026-04-15 23:15:58 -04:00
skill feat: enable type-aware no-floating-promises rule, fix all 177 violations (#22741) 2026-04-15 23:27:32 -04:00
snapshot feat: unwrap 11 util namespaces to flat exports + barrel (#22739) 2026-04-15 23:15:58 -04:00
storage CLI perf: reduce deps (#22652) 2026-04-16 02:03:03 -04:00
sync fix: add a few more tests for sync and session restore (#22837) 2026-04-16 12:15:44 -04:00
tool fix: bound LSP diagnostic enrichment in write/edit/apply_patch (#22872) 2026-04-16 17:36:04 -04:00
util CLI perf: reduce deps (#22652) 2026-04-16 02:03:03 -04:00
workspace fix: add a few more tests for sync and session restore (#22837) 2026-04-16 12:15:44 -04:00
AGENTS.md refactor(file): destroy FileTime facade (#22090) 2026-04-11 20:08:55 -04:00
keybind.test.ts feat: unwrap 11 util namespaces to flat exports + barrel (#22739) 2026-04-15 23:15:58 -04:00
npm.test.ts fix(plugin): parse package specifiers with npm-package-arg and sanitize win32 cache paths (#21135) 2026-04-06 00:26:40 +00:00
permission-task.test.ts feat: unwrap Config namespace to flat exports + barrel (#22689) 2026-04-15 21:26:24 -04:00
preload.ts feat: unwrap storage namespaces to flat exports + barrel (#22747) 2026-04-15 23:30:49 -04:00