Local projects run as their own processes again: no compile cache for a local command, and plain words when the server's code can't load Version 289 of shared· pinch· Oct 16 (2026-10-16 03:13 UTC) · Not checked
At 287, every local command run as node client/abso.ts could crash with a segmentation fault (exit 139, at random, init and join included). The cause is Node's compile cache, which client/avcs.ts turns on, together with the module hook that gives the open server's code its cloudflare:workers stand-in. avcs.ts now leaves the cache off for a --local command and in a folder whose config names the server "local". The hook also stays registered rather than being removed after the import.
If the server's code can't load (a package missing, say), it's said as "local projects couldn't load the server's code: ..." rather than "Can't reach local ... check your connection". In a local folder, status says "It's a local project, in <store>/<project>." instead of "Signed in with none.", and skips the npm newer-client check, which reaches for the network. worker/project/news.ts is Biome-formatted (only formatting), so the check gets past Biome again. scripts/local-measure.ts times status, log, blame, pull and push as separate processes on a small and a large local history, with peak memory and the store's size. scripts/local-writers.ts pushes from 1, 4 and 16 writers at once to measure the store lock. Tests: client/test/local.test.ts (9, one running init, push, status and log as child processes with the cache as it is); tsc and Biome clean. Three rounds of init, push and status as processes exit 0.
Version 288 · Files at version 289
7 files, 285 lines added, 16 removed.
--- a/client/avcs.ts
+++ b/client/avcs.ts
@@ -3,15 +3,33 @@
3 3 // `abso help` lists the commands. `abso hook` is the Claude Code hook; it 4 4 // loads only what it needs, since every edit pays for its start-up. 6 + import { readFileSync } from "node:fs"; 6 7 import * as nodeModule from "node:module"; 8 + import { dirname, join } from "node:path"; 10 + const argv = process.argv.slice(2); 13 + * Whether this command opens a local project (abso init --local): --local, or a folder whose config names the server 14 + * "local". Those load the open server's code through a module hook, and with the compile cache on Node 24 crashes. 16 + function opensLocal(): boolean { 17 + if (argv.includes("--local")) return true; 18 + for (let dir = process.cwd(); ; dir = dirname(dir)) { 19 + for (const state of [".abso", ".avcs"]) { 21 + return /"server"\s*:\s*"local"/.test(readFileSync(join(dir, state, "config.json"), "utf8")); 24 + if (dirname(dir) === dir) return false; 8 28 // Node keeps the compiled modules (TypeScript already stripped) in a cache in 9 29 // the temp folder. Loading the hook's modules drops from about 55 ms to 11 ms. 10 30 // Node 20 has no compile cache, and the built client runs there without one. 11 − (nodeModule as { enableCompileCache?: () => unknown }).enableCompileCache?.();
31 + if (!opensLocal()) (nodeModule as { enableCompileCache?: () => unknown }).enableCompileCache?.(); 13 − const argv = process.argv.slice(2);
14 −
15 33 if (argv[0] === "hook") { 16 34 const { runHook } = await import("./src/hook.ts"); 17 35 const chunks: Buffer[] = []; --- a/client/src/local-store.ts
+++ b/client/src/local-store.ts
@@ -221,24 +221,26 @@
221 221 // copy has it already: the build points the import at the same file (scripts/build-client.mjs). 222 222 const standIn = new URL("./durable-object-stand-in.ts", import.meta.url).href; 223 223 const mod = (await import("node:module")) as unknown as { 224 − registerHooks?: (hooks: unknown) => { deregister(): void };
224 + registerHooks?: (hooks: unknown) => unknown; 226 − const hooks = mod.registerHooks?.({
226 + // The hook stays for the rest of the process: deregistering it crashes Node 24 at exit when the compile cache 227 + // is on (client/avcs.ts turns it on). It answers only cloudflare:workers. 228 + mod.registerHooks?.({ 227 229 resolve(specifier: string, context: unknown, next: (s: string, c: unknown) => unknown) { 228 230 if (specifier === "cloudflare:workers") return { url: standIn, shortCircuit: true }; 229 231 return next(specifier, context); 234 + let loaded: typeof import("./local-server.mjs"); 233 − const { handle, ProjectObject } = await import("./local-server.mjs");
234 − return {
235 − DatabaseSync: sqlite.DatabaseSync,
236 − handle,
237 − ProjectObject,
238 − };
239 − } finally {
240 − hooks?.deregister();
236 + loaded = await import("./local-server.mjs"); 238 + // Nothing is reached for here: a part of the client is missing (its packages not installed, say). 239 + throw new LocalError( 240 + `local projects couldn't load the server's code: ${e instanceof Error ? e.message : String(e)}`, 243 + return { DatabaseSync: sqlite.DatabaseSync, handle: loaded.handle, ProjectObject: loaded.ProjectObject }; --- a/client/src/status-commands.ts
+++ b/client/src/status-commands.ts
@@ -40,6 +40,7 @@
40 40 } from "./folder.ts"; 41 41 import { fileArg } from "./history.ts"; 42 42 import { modsBehindText } from "./install.ts"; 43 + import { isLocal } from "./local-store.ts"; 43 44 import { withFolderLock } from "./lock.ts"; 44 45 import { readKnownModes, writeKnownModes } from "./modes.ts"; 45 46 import { queueText } from "./queue.ts"; @@ -325,9 +326,11 @@
325 326 const space = (draft: string | null | undefined): string => (draft ? `draft ${draft}` : "shared"); 326 327 const parked = (me?.parked ?? []).filter((p) => p.draftChanges > 0); 327 328 const credential = credentialLabel(root, config.server, env.env); 328 − const behind = await newerClientNote(config.server);
329 + // A local project reaches for nothing on the network, npm included. 330 + const localProject = isLocal(config.server); 331 + const behind = localProject ? undefined : await newerClientNote(config.server); 330 − `Project ${config.project}: shared is at version ${status.version}. This folder is ${config.agent}${config.reader || me?.reader ? ", a reader (it records and pushes nothing)" : ""}, working in ${space(me?.draft)}.${config.follow ? ` It follows label ${config.follow}: pulls take it to the newest version with that label.` : ""} Signed in with ${credential.kind}${credential.id ? ` ${credential.id}` : ""}.`,
333 + `Project ${config.project}: shared is at version ${status.version}. This folder is ${config.agent}${config.reader || me?.reader ? ", a reader (it records and pushes nothing)" : ""}, working in ${space(me?.draft)}.${config.follow ? ` It follows label ${config.follow}: pulls take it to the newest version with that label.` : ""}${localProject ? ` It's a local project, in ${join(config.localStore ?? "", config.project)}.` : ` Signed in with ${credential.kind}${credential.id ? ` ${credential.id}` : ""}.`}`, 331 334 ...(behind ? [behind] : []), 332 335 // Is shared green (#39)? Right under the first line, since it decides what to do next. 333 336 ...ciText(status.ci, status.version), --- a/client/test/local.test.ts
+++ b/client/test/local.test.ts
@@ -3,10 +3,12 @@
3 3 // call that would leave the machine fails the test. 5 5 import assert from "node:assert/strict"; 6 + import { spawnSync } from "node:child_process"; 6 7 import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; 7 8 import { tmpdir } from "node:os"; 8 9 import { join } from "node:path"; 9 10 import { after, before, describe, it } from "node:test"; 11 + import { fileURLToPath } from "node:url"; 10 12 import { main } from "../src/main.ts"; 11 13 import { stateDir } from "../src/state-dir.ts"; @@ -138,3 +140,33 @@
138 140 assert.equal(existsSync(join(dir, ".abso")) || existsSync(join(dir, ".avcs")), false); 144 + describe("local commands as their own processes", () => { 145 + // The way people and agents run them: client/abso.ts, a process per command, Node's compile cache as it is. 146 + const entry = fileURLToPath(new URL("../abso.ts", import.meta.url)); 147 + const cli = (cwd: string, processStore: string, ...argv: string[]) => 148 + spawnSync(process.execPath, [entry, ...argv], { 150 + env: { ...process.env, ABSO_STORE: processStore, ABSO_SERVERS_FILE: "no-servers.json" }, 154 + it("init, push, status and log each exit cleanly", () => { 155 + const processStore = temp("process-store"); 156 + const dir = temp("process"); 157 + writeFileSync(join(dir, "a.txt"), "one\n"); 158 + const steps: [string, string[]][] = [ 159 + ["init", ["init", "--local", "--project", "proc", "--agent", "p"]], 160 + ["push", ["push", "-m", "Two"]], 161 + ["status", ["status"]], 164 + for (const [name, argv] of steps) { 165 + if (name === "push") writeFileSync(join(dir, "a.txt"), "one\ntwo\n"); 166 + const r = cli(dir, processStore, ...argv); 167 + assert.equal(r.status, 0, `${name}: exit ${r.status} ${r.signal ?? ""}\n${r.stdout}${r.stderr}`); 168 + if (name === "status") assert.match(r.stdout, /It's a local project, in /); 169 + if (name === "log") assert.match(r.stdout, /Two/); --- /dev/null
+++ b/scripts/local-measure.ts
@@ -0,0 +1,123 @@
1 + // Time and memory of a local project's commands (abso init --local) on a small and a large history: 3 + // node scripts/local-measure.ts [versions ...] (default: 20 1000) 5 + // Each history is built in this process through the client's main(); then every command is run as its own 6 + // `node client/abso.ts` process, the way a person or an agent runs it, five times. It prints the median and slowest 7 + // wall time, and the largest peak memory (maxRSS) of those runs, with the store's size on disk. 9 + import { spawnSync } from "node:child_process"; 10 + import { mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs"; 11 + import { tmpdir } from "node:os"; 12 + import { join, resolve } from "node:path"; 13 + import { fileURLToPath, pathToFileURL } from "node:url"; 14 + import { main } from "../client/src/main.ts"; 16 + const ROOT = resolve(fileURLToPath(new URL("..", import.meta.url))); 17 + const ENTRY = join(ROOT, "client", "abso.ts"); 21 + const sizes = process.argv.slice(2).map(Number); 22 + const histories = sizes.length > 0 ? sizes : [20, 1000]; 24 + function sizeOf(dir: string): number { 26 + for (const name of readdirSync(dir)) { 27 + const path = join(dir, name); 28 + const s = statSync(path); 29 + total += s.isDirectory() ? sizeOf(path) : s.size; 34 + const lines = (file: number, version: number) => 35 + Array.from({ length: 30 }, (_, i) => 36 + i === version % 30 ? `line ${i} of file ${file}, version ${version}` : `line ${i} of file ${file}`, 41 + async function build(versions: number): Promise<{ store: string; alice: string; bob: string }> { 42 + const store = mkdtempSync(join(tmpdir(), "abso-measure-store-")); 43 + const alice = mkdtempSync(join(tmpdir(), "abso-measure-alice-")); 44 + const bob = mkdtempSync(join(tmpdir(), "abso-measure-bob-")); 45 + const env = { ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" }; 46 + const run = async (cwd: string, ...argv: string[]) => { 47 + const r = await main(argv, { cwd, env, write: () => {} }); 48 + if (r.exit !== 0) throw new Error(`${argv.join(" ")}: ${r.stdout}${r.stderr}`); 50 + for (let f = 0; f < FILES; f++) writeFileSync(join(alice, `f${f}.txt`), lines(f, 0)); 51 + await run(alice, "init", "--local", "--project", "measure", "--agent", "alice", "--as-is"); 52 + for (let v = 1; v < versions; v++) { 53 + // Each version changes three files, as a small piece of work does. 54 + for (const f of [v % FILES, (v * 7) % FILES, (v * 13) % FILES]) 55 + writeFileSync(join(alice, `f${f}.txt`), lines(f, v)); 56 + await run(alice, "push", "-m", `Version ${v}`); 58 + await run(bob, "join", "measure", "--local", "--agent", "bob", "--dir", bob); 59 + return { store, alice, bob }; 62 + function measure(cwd: string, store: string, argv: string[]): { median: number; slowest: number; rss: number } { 63 + const times: number[] = []; 65 + const preload = join(tmpdir(), `abso-measure-rss-${process.pid}.mjs`); 66 + const out = join(tmpdir(), `abso-measure-rss-${process.pid}.json`); 69 + `import { writeFileSync } from "node:fs";\nprocess.on("exit", () => writeFileSync(${JSON.stringify(out)}, String(process.resourceUsage().maxRSS)));\n`, 71 + for (let i = 0; i < RUNS; i++) { 72 + const started = performance.now(); 73 + const r = spawnSync(process.execPath, ["--import", pathToFileURL(preload).href, ENTRY, ...argv], { 75 + env: { ...process.env, ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" }, 78 + times.push(performance.now() - started); 79 + if (r.status !== 0 && argv[0] !== "push") throw new Error(`${argv.join(" ")}: ${r.stdout}${r.stderr}`); 85 + ["-e", `process.stdout.write(require("fs").readFileSync(${JSON.stringify(out)}, "utf8"))`], 86 + { encoding: "utf8" }, 91 + times.sort((a, b) => a - b); 92 + return { median: times[Math.floor(RUNS / 2)]!, slowest: times[RUNS - 1]!, rss }; 95 + const kb = (n: number) => `${(n / 1024).toFixed(0)} MB`; 96 + const ms = (n: number) => `${n.toFixed(0)} ms`; 98 + `Node ${process.versions.node}, ${FILES} files of 30 lines, three files changed per version, ${RUNS} runs each.`, 100 + console.log("history | command | median | slowest | peak memory"); 101 + for (const versions of histories) { 102 + const started = performance.now(); 103 + const { store, alice, bob } = await build(versions); 104 + const built = performance.now() - started; 105 + const steps: [string, string, string[]][] = [ 106 + ["status", alice, ["status"]], 107 + ["log", alice, ["log"]], 108 + ["blame", alice, ["blame", "f0.txt"]], 109 + ["pull (no change)", bob, ["pull"]], 110 + ["record + push", alice, ["push", "-m", "One more"]], 112 + for (const [name, cwd, argv] of steps) { 113 + if (argv[0] === "push") writeFileSync(join(cwd, "f1.txt"), lines(1, versions + Math.random())); 114 + const m = measure(cwd, store, argv); 116 + `${String(versions).padStart(5)} v | ${name.padEnd(20)} | ${ms(m.median).padStart(8)} | ${ms(m.slowest).padStart(8)} | ${kb(m.rss)}`, 120 + `${String(versions).padStart(5)} v | store on disk ${(sizeOf(store) / 1048576).toFixed(1)} MB, built in-process in ${(built / 1000).toFixed(1)} s`, 122 + for (const d of [store, alice, bob]) rmSync(d, { recursive: true, force: true, maxRetries: 5 }); --- /dev/null
+++ b/scripts/local-writers.ts
@@ -0,0 +1,87 @@
1 + // A local project's store lock under load: 1, 4 and 16 writers pushing to one local project at once. 3 + // node scripts/local-writers.ts [writers ...] (default: 1 4 16; PUSHES=10 pushes per writer) 5 + // Each writer is its own agent, in its own folder, changing its own file, so nothing collides: what's measured is the 6 + // store's lock (one SQLite write transaction per call). Every push is its own `node client/abso.ts push` process, as 7 + // an agent runs it. It prints each push's wall time (median, 95th percentile, slowest), the pushes per second across 8 + // all writers, and any push that failed. 10 + import { spawn } from "node:child_process"; 11 + import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; 12 + import { tmpdir } from "node:os"; 13 + import { join, resolve } from "node:path"; 14 + import { fileURLToPath } from "node:url"; 15 + import { main } from "../client/src/main.ts"; 17 + const ROOT = resolve(fileURLToPath(new URL("..", import.meta.url))); 18 + const ENTRY = join(ROOT, "client", "abso.ts"); 19 + const PUSHES = Number(process.env.PUSHES ?? 10); 20 + const counts = process.argv.slice(2).map(Number); 22 + function push(cwd: string, store: string, message: string): Promise<{ ms: number; ok: boolean; out: string }> { 23 + const started = performance.now(); 24 + return new Promise((done) => { 25 + const child = spawn(process.execPath, [ENTRY, "push", "-m", message], { 27 + env: { ...process.env, ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" }, 30 + child.stdout.on("data", (d) => { 33 + child.stderr.on("data", (d) => { 36 + child.on("close", (code) => done({ ms: performance.now() - started, ok: code === 0, out })); 40 + const pct = (sorted: number[], p: number) => sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * p))]!; 41 + console.log(`Node ${process.versions.node}, ${PUSHES} pushes per writer, each writer its own agent and file.`); 42 + console.log("writers | pushes | median | p95 | slowest | pushes/s | failed"); 43 + for (const writers of counts.length > 0 ? counts : [1, 4, 16]) { 44 + const store = mkdtempSync(join(tmpdir(), "abso-writers-store-")); 45 + const folders: string[] = []; 46 + const env = { ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" }; 47 + const first = mkdtempSync(join(tmpdir(), "abso-writers-w0-")); 48 + writeFileSync(join(first, "readme.txt"), "writers\n"); 49 + const init = await main(["init", "--local", "--project", "writers", "--agent", "w0", "--as-is"], { 54 + if (init.exit !== 0) throw new Error(init.stdout + init.stderr); 56 + for (let w = 1; w < writers; w++) { 57 + const dir = mkdtempSync(join(tmpdir(), `abso-writers-w${w}-`)); 58 + const joined = await main(["join", "writers", "--local", "--agent", `w${w}`, "--dir", dir], { 63 + if (joined.exit !== 0) throw new Error(joined.stdout + joined.stderr); 66 + const times: number[] = []; 67 + const failures: string[] = []; 68 + const started = performance.now(); 70 + folders.map(async (dir, w) => { 71 + for (let i = 0; i < PUSHES; i++) { 72 + writeFileSync(join(dir, `w${w}.txt`), `writer ${w}, push ${i}\n`); 73 + const r = await push(dir, store, `w${w} push ${i}`); 75 + if (!r.ok) failures.push(`w${w} push ${i}: ${r.out.trim().split("\n").slice(-2).join(" / ")}`); 79 + const total = (performance.now() - started) / 1000; 80 + times.sort((a, b) => a - b); 81 + const ms = (n: number) => `${n.toFixed(0)} ms`.padStart(8); 83 + `${String(writers).padStart(7)} | ${String(times.length).padStart(6)} | ${ms(pct(times, 0.5))} | ${ms(pct(times, 0.95))} | ${ms(times.at(-1)!)} | ${(times.length / total).toFixed(1).padStart(8)} | ${failures.length}`, 85 + for (const f of failures.slice(0, 5)) console.log(` ${f}`); 86 + for (const d of [store, ...folders]) rmSync(d, { recursive: true, force: true, maxRetries: 5 }); --- a/worker/project/news.ts
+++ b/worker/project/news.ts
@@ -361,7 +361,11 @@
361 361 changedNames.size > 0 362 362 ? host.definitionCollisions(agent, host.newerFor(agent), changedNames).filter((d) => just.has(d.by)) 364 − const items = [...lineNews(host, agent, lines), ...definitionNews(defs), ...moveNews(host, draft, just, space, version)];
365 + ...lineNews(host, agent, lines), 366 + ...definitionNews(defs), 367 + ...moveNews(host, draft, just, space, version), 365 369 news += items.length; 366 370 host.queueNews(agent, items, entries);