From 1611b405d53444bb45d6c20a77d8edee1eb6026d Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Mon, 16 Nov 2026 09:18:23 +0000 Subject: [PATCH] docs(apidocs): refresh TypeScript reference for builtin cancellation The weekly API Reference Drift job went red on main (run 126, Mon Nov 16 06:14 UTC): site/src/content/apidocs/typescript.md no longer matched what scripts/gen_ts_apidocs.mjs produces from the wrappers, so the committed reference behind the /api/typescript page was serving a CommandContext that no longer exists. #2893 gave custom builtins execution-scoped cancellation and added four members to the TypeScript CommandContext - the signal property plus the fetch, onCancel and throwIfCancelled methods - without regenerating the committed markdown. Nothing was missed in review: the typescript job of apidocs-drift.yml is deliberately `if: github.event_name != 'pull_request'` because the .ts wrappers import types from the napi-generated index.d.ts, so regeneration needs a Rust build that is too heavy per-PR. #2893 landed 2026-11-09, hours after that Monday's weekly run (122) had already passed, so today's run was the first to see it. The python job needs only griffe and does gate per-PR, which is why python.md has not drifted. Regenerated output only, 32 added lines documenting those four members in the shape typedoc emits. No wrapper, binding or site code changed, and no existing entry moved. Verified: local `pnpm exec napi build --platform` + `build:cjs` + `node scripts/gen_ts_apidocs.mjs` reproduces CI's diff exactly, down to the 74403-byte output size the failed run reported, and a second run is idempotent. `just check-doc-links` passes - 221 relative links and 10 dependency versions across 52 files. --- site/src/content/apidocs/typescript.md | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/site/src/content/apidocs/typescript.md b/site/src/content/apidocs/typescript.md index ae914ec1f..b885ee535 100644 --- a/site/src/content/apidocs/typescript.md +++ b/site/src/content/apidocs/typescript.md @@ -1441,10 +1441,42 @@ virtual filesystem. - **`name`** — `string` The command name as invoked. +- **`signal`** — `AbortSignal` + + Execution-scoped cancellation signal. + + Aborted on `bash.cancel()`, caller `signal` abort, and execution timeout. + Pass to `fetch` (or use `ctx.fetch`) so hanging I/O aborts promptly. - **`stdin`** — `null | string` Piped input, or `null` if there is no pipe. +### `fetch` + +```typescript +fetch(input: any, init?: any): Promise +``` + +Cancellation-aware fetch: combines `signal` with `init.signal` +so either source aborts the request. + +### `onCancel` + +```typescript +onCancel(handler: () => void): () => void +``` + +Run `handler` on cancellation. Returns an unsubscribe function. +The handler fires at most once per invocation. + +### `throwIfCancelled` + +```typescript +throwIfCancelled(): void +``` + +Throw an `AbortError` when `signal` is aborted. + ## CapabilityFingerprint The environment that produced a commit.