Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

wasCancelRequested.md

39 lines1.3 KB

1---
2id: wasCancelRequested
3title: wasCancelRequested
4---
5​
6```ts
7function wasCancelRequested(runs, runId): Promise<boolean>;
8```
9​
10Defined in: [packages/ai/src/activities/chat/cancel.ts:71](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/cancel.ts#L71)
11​
12Whether an explicit cancel has been recorded for `runId`.
13​
14Answers `false` rather than throwing when the store cannot be read. Callers
15are middleware abort hooks, which are already on a teardown path, and a
16store failure there must not replace the caller's own reason for tearing
17down with a store error. The cost of a false negative is that a cancel
18degrades into a detach — the run record gains `detachedSince`/`sandboxKey`
19instead of transitioning to `'aborted'`. `@tanstack/ai-sandbox`'s
20`reapDetachedRuns` recovers that run once the `detachedRunTtlMs` the
21application passes to that sweep has elapsed — nothing derives it from
22`withSandbox`, which has no TTL option — so the cost is a delayed teardown
23rather than a lost one, provided the application actually schedules the
24sweep, which is its job and not the framework's. Still strictly better than
25failing the teardown.
26​
27## Parameters
28​
29### runs
30​
31[`RunStore`](../interfaces/RunStore.md)
32​
33### runId
34​
35`string`
36​
37## Returns
38​
39`Promise`\<`boolean`\>