Skip to content

Commit ef88e37

Browse files
committed
fix
1 parent a2ba03f commit ef88e37

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

docs/advanced-apis/lsp.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,11 @@ const handle = lsp.workers.createTransport({
407407
- Starts a `Worker` from `url`
408408
- Posts an optional `configure` payload
409409
- Resolves `ready` when the worker sends `{ kind: "ready" }`
410+
- Rejects `ready` when the worker sends `{ kind: "error" }`, fires `onerror`, or hits the startup timeout
410411
- Forwards JSON-RPC **string** messages between CodeMirror and the worker
411412
- Dispatches `{ kind: "host-request" }` to `hostHandlers` and replies with `{ kind: "host-response" }`
412413
- Forwards `{ kind: "log" }` / `{ kind: "status" }` to Acode's LSP logs
413-
- Rejects `ready` if the worker errors or the startup timeout elapses
414-
- Terminates the worker on `dispose()`
414+
- Terminates the worker on `dispose()` or on `{ kind: "error" }`
415415
416416
### `lsp.workers.createTransport(options)`
417417
@@ -443,12 +443,20 @@ Returns a `TransportHandle`:
443443
}
444444
```
445445
446-
**Ready** (worker → main):
446+
**Ready** (worker → main) after successful initialization:
447447
448448
```js
449449
{ kind: "ready" }
450450
```
451451
452+
**Error** (worker → main) if initialization fails — rejects `ready` immediately and tears down the worker:
453+
454+
```js
455+
{ kind: "error", message: "Failed to initialize worker" }
456+
```
457+
458+
Prefer this over throwing from the configure path. An uncaught rejection does not always surface as `Worker.onerror`, so the host would otherwise wait until `startupTimeout`.
459+
452460
**JSON-RPC** as strings in both directions (no LSP headers):
453461
454462
```js

0 commit comments

Comments
 (0)