Skip to content

Commit 67ce22f

Browse files
committed
computer, docs: Mark restart and replay as experimental
The journal format, event log and fingerprint check will change as replay develops, and a run interrupted across such a change fails rather than resuming. WorkerJavaScriptBackend and workspace.runtime are now listed as stable, so give resuming its own experimental row in the package's status table, and say so in the docs, the onInterrupt JSDoc and the changeset. The changeset also notes the new required callId on host module call contexts. A comment on the durable tables records why a change to their shape should rename them rather than migrate: every backend creates them when it connects, and CREATE TABLE IF NOT EXISTS leaves an older table as it was.
1 parent e1841b8 commit 67ce22f

6 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎.changeset/durable-javascript.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@cloudflare/computer": minor
33
---
44

5-
`WorkerJavaScriptBackend` can restart or replay runs interrupted by a deploy or crash, with the `onInterrupt` option and `runtime.recover()`. Host module functions can opt out of running twice with `unsafeToRepeat()`.
5+
`WorkerJavaScriptBackend` can restart or replay runs interrupted by a deploy or crash, with the experimental `onInterrupt` option and `runtime.recover()`. Host module functions can opt out of running twice with `unsafeToRepeat()`. Host module call contexts now carry a required `callId`.

‎docs/17_isolate_javascript.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ A deploy or a crash still ends a run. A deploy shuts the old instance down a few
147147

148148
## Interrupted executions
149149

150-
A run that was in flight when its Durable Object restarted is settled by its `onInterrupt` policy. Set a default on the backend and override it per run:
150+
A run that was in flight when its Durable Object restarted is settled by its `onInterrupt` policy. Set a default on the backend and override it per run. The `"restart"` and `"replay"` policies are [experimental](../packages/computer/README.md#status): their behavior and stored format may change in any release, and a run interrupted across such an upgrade fails rather than resuming.
151151

152152
```ts
153153
const backend = new WorkerJavaScriptBackend({ loader: env.LOADER, onInterrupt: "replay" });

‎packages/computer/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ removed in a future release; each one names its replacement.
3131
| Observability hook and its Cloudflare adapter | `@cloudflare/computer`, `@cloudflare/computer/observe/cloudflare` | Stable |
3232
| `ContainerBackend` and `withWorkspaceContainer` | `@cloudflare/computer/backends/container` | Experimental |
3333
| `LegacyContainerBackend` and `withLegacyWorkspaceContainer` | `@cloudflare/computer/backends/container-legacy` | Deprecated: use `ContainerBackend` |
34+
| Resuming interrupted isolate JavaScript: `onInterrupt: "restart"` and `"replay"`, `workspace.runtime.recover()`, and `unsafeToRepeat()` | `@cloudflare/computer`, `@cloudflare/computer/backends/worker-javascript` | Experimental |
3435
| `WorkerShellBackend` and the shell command groups | `@cloudflare/computer/backends/worker-shell`, `@cloudflare/computer/shell/*` | Experimental |
3536
| The `ws:container` host module | `@cloudflare/computer/modules/container` | Experimental |
3637
| `workspace.push()`, `workspace.pull()`, and the sync protocol between the durable object and `computerd` | `@cloudflare/computer` | Experimental |

‎packages/computer/src/backends/worker-javascript/journal.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export const DURABLE_TABLES = [
104104
/** Most events one log chunk may carry. */
105105
const MAX_LOG_CHUNK = 65536;
106106

107+
// The tables hold state for running executions only. A change to their
108+
// shape should rename them rather than migrate: every backend creates
109+
// them on connect, whether or not it uses them, and CREATE TABLE IF NOT
110+
// EXISTS leaves an older table as it was.
107111
export function createDurableTables(db: Database): void {
108112
db.run(`
109113
CREATE TABLE IF NOT EXISTS workspace_runtime_durable (

‎packages/computer/src/backends/worker-javascript/worker-javascript.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export interface WorkerJavaScriptBackendOptions {
107107
* attempts and must finish within its original timeout. A call in
108108
* flight at the interruption runs again, unless it's marked with
109109
* `unsafeToRepeat()`.
110+
*
111+
* `"restart"` and `"replay"` are experimental and may change in any
112+
* release.
110113
*/
111114
onInterrupt?: WorkspaceRuntimeInterruptPolicy;
112115
/**

‎packages/computer/src/runtime/types.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ export interface ModuleExecutionInput {
278278
* What a backend does with a run its Durable Object restarted under.
279279
* `fail` settles it as failed. `restart` runs it again from the start.
280280
* `replay` runs it again and answers the calls it already made from a
281-
* journal, so their effects aren't repeated.
281+
* journal, so their effects aren't repeated. `restart` and `replay` are
282+
* experimental and may change in any release.
282283
*/
283284
export type WorkspaceRuntimeInterruptPolicy = "fail" | "restart" | "replay";
284285

0 commit comments

Comments
 (0)