A handler is a live reference, held by the VatAdmin DO; workerd evicts an idle DO within seconds, and with it the handler, so a vat's page went 503 almost at once. createVat now keeps a vat's params when they hold only data and ingresses (an ingress by its key: the VatAdmin can make it again), and which vat was given which ingress. A request for a mount with no handler restarts that vat with its params; it rebuilds its root, serves again, and the request is answered. A vat whose params hold another peer's objects isn't restartable yet. The test crashes its own toybox (a crash ends every session to it), and the creator waits for the root's handoff before it disconnects, as scripts/hello.js now does too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
21 lines
806 B
JavaScript
21 lines
806 B
JavaScript
/**
|
|
* @file Create the hello-world vat on a running toybox and mount it.
|
|
*
|
|
* Usage: node --import ./test/lockdown.js scripts/hello.js [name]
|
|
* then visit http://127.0.0.1:8787/?vat=<name> (default name: hello).
|
|
*/
|
|
import { readFile } from "node:fs/promises";
|
|
import { E } from "@endo/far";
|
|
import { connectClient } from "../client.js";
|
|
|
|
const name = process.argv[2] ?? "hello";
|
|
const client = await connectClient("admin.sock", `hello-script-${process.pid}`);
|
|
try {
|
|
const ingress = await E(client.vatAdmin).makeIngress({ vat: name });
|
|
const { id, root } = await E(client.vatAdmin).createVat(await readFile("vats/hello.js", "utf8"), { ingress });
|
|
await root; // its handoff, settled before the client goes
|
|
console.log(`vat ${id}\nhttp://127.0.0.1:8787/?vat=${name}`);
|
|
} finally {
|
|
client.close();
|
|
}
|