@ai-ecoverse/slicc-kernel 1.65.1 → 1.65.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -392,7 +392,7 @@ The proxy answers `200` with `Content-Type: application/vnd.slicc.raw-fetch`: a
392
392
 
393
393
  ## Filesystem
394
394
 
395
- `/` is the OPFS root. Each process mounts the top-level directories that exist when it starts (plus `/usr` and `/bin`), so files in them are shared by all processes and visible through the OPFS API as soon as the process that wrote them has closed them; `run` resolves only after that. `createKernel` creates `/tmp` and `/home` in OPFS, so they are shared too. Files directly in `/`, and directories created there after a process started, are OPFS as well, the same for Emscripten and WASI programs; only `/dev` and `/proc` live in each process's memory. A program's `mkdir` (WASI `path_create_directory`, Emscripten's `mkdir`) is exclusive, as on Linux: it fails with `EEXIST` when the name exists, and of several processes or threads making one name at once exactly one succeeds, so a directory works as a lock. Under a missing directory it fails with `ENOENT`, as on Linux (`mkdir -p` and `os.makedirs` make the parents in the program); a JS program's `ctx.fs.mkdir` makes parents itself. The kernel makes the system `PNPM_HOME` (`/usr/local/share/pnpm`, or the embedder's) when it starts, since pnpm makes only its `bin` directory there. An OPFS or IndexedDB failure that has no POSIX counterpart is `EIO`; its message names the DOM error and the operation (`lookup`, `read`, `write`, `commit` or `sidecar`), and the kernel worker logs the first of each kind to its console. File contents are buffered per open file and written back on close, `fsync` and exit; metadata operations (`mkdir`, `rename`, `rm`, …) go straight to OPFS. The kernel worker is the only writer.
395
+ `/` is the OPFS root. Each process mounts the top-level directories that exist when it starts (plus `/usr` and `/bin`), so files in them are shared by all processes and visible through the OPFS API as soon as the process that wrote them has closed them; `run` resolves only after that. `createKernel` creates `/tmp` and `/home` in OPFS, so they are shared too. Files directly in `/`, and directories created there after a process started, are OPFS as well, the same for Emscripten and WASI programs; only `/dev` and `/proc` live in each process's memory. A program's `mkdir` (WASI `path_create_directory`, Emscripten's `mkdir`) is exclusive, as on Linux: it fails with `EEXIST` when the name exists, and of several processes or threads making one name at once exactly one succeeds, so a directory works as a lock. Under a missing directory it fails with `ENOENT`, as on Linux (`mkdir -p` and `os.makedirs` make the parents in the program); a JS program's `ctx.fs.mkdir` makes parents itself. The kernel makes the system `PNPM_HOME` (`/usr/local/share/pnpm`, or the embedder's) when it starts, since pnpm makes only its `bin` directory there. A full origin storage (`QuotaExceededError`, which also comes early in a browser's private or off-the-record contexts, whatever `navigator.storage.estimate()` says) is `ENOSPC`, never retried. An OPFS or IndexedDB failure that has no POSIX counterpart is `EIO`; its message names the DOM error and the operation (`lookup`, `read`, `write`, `commit` or `sidecar`), and the kernel worker logs the first of each kind to its console. File contents are buffered per open file and written back on close, `fsync` and exit; metadata operations (`mkdir`, `rename`, `rm`, …) go straight to OPFS. The kernel worker is the only writer.
396
396
 
397
397
  Directories are renamed with `FileSystemHandle.move()` where available, else by copy and delete.
398
398
 
@@ -376,15 +376,15 @@ function translate(err, path, op = "lookup", mapped = true) {
376
376
  if (typeof err?.code === "string") return err;
377
377
  const raw = err?.name;
378
378
  const name2 = typeof raw === "string" ? raw : "Error";
379
- const code = mapped && ERRNO_BY_DOM_ERROR[name2] || "EIO";
379
+ const code = name2 === "QuotaExceededError" ? "ENOSPC" : mapped && ERRNO_BY_DOM_ERROR[name2] || "EIO";
380
380
  const error = Object.assign(fsError(code, path), { domName: name2, op, cause: err });
381
- if (code !== "EIO") return error;
381
+ if (code !== "EIO" && code !== "ENOSPC") return error;
382
382
  const detail = err?.message;
383
383
  error.message += ` (OPFS ${op}: ${name2}${typeof detail === "string" && detail ? `: ${detail}` : ""})`;
384
384
  if (!reported.has(`${name2}/${op}`)) {
385
385
  reported.add(`${name2}/${op}`);
386
386
  console.warn(
387
- `slicc-kernel: ${error.message}, reported as EIO; logged once per error and operation`
387
+ `slicc-kernel: ${error.message}, reported as ${code}; logged once per error and operation`
388
388
  );
389
389
  }
390
390
  return error;
@@ -894,11 +894,13 @@ var OpfsFs = class {
894
894
  const [file, existed, target] = await this.fileFor(path);
895
895
  if (!existed) await this.stampNew(target, owner, false);
896
896
  if (!existed && content.length === 0) return;
897
+ let writable2;
897
898
  try {
898
- const writable2 = await file.createWritable();
899
+ writable2 = await file.createWritable();
899
900
  await writable2.write(content);
900
901
  await writable2.close();
901
902
  } catch (err) {
903
+ await writable2?.abort().catch(() => void 0);
902
904
  throw translate(err, path, "commit", false);
903
905
  }
904
906
  }