@waffle-os/runtime 0.0.151 → 0.0.152

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.
@@ -211,6 +211,8 @@ export function isPeerMessage(value) {
211
211
  return typeof value.reqId === "number" && typeof value.op === "string" && Array.isArray(value.args);
212
212
  case "chunk-put":
213
213
  return typeof value.reqId === "number" && typeof value.uploadId === "string" && typeof value.offset === "number" && typeof value.totalBytes === "number" && value.chunk instanceof Uint8Array;
214
+ case "chunk-abort":
215
+ return typeof value.uploadId === "string";
214
216
  case "chunk-get":
215
217
  return typeof value.reqId === "number" && typeof value.downloadId === "string" && typeof value.offset === "number" && typeof value.length === "number";
216
218
  case "res":
@@ -973,14 +973,36 @@ export class FilesystemService {
973
973
  return;
974
974
  }
975
975
  if (operation === "flush" || operation === "sync") {
976
- const flushing = this.backend.flush?.(operation === "sync" ? a : typeof a === "string" ? a : undefined);
977
- return this.trackRequestWork(session, Promise.resolve(flushing)).then(() => this.finishResult(session, id, operation, operation === "sync" ? 0 : undefined));
976
+ const target = operation === "sync" ? a : typeof a === "string" ? a : undefined;
977
+ if (operation === "sync")
978
+ this.backend.retain(a);
979
+ let flushing;
980
+ try {
981
+ flushing = this.backend.flush?.(target);
982
+ } catch (error) {
983
+ if (operation === "sync")
984
+ this.backend.release(a);
985
+ throw error;
986
+ }
987
+ return this.trackRequestWork(session, Promise.resolve(flushing)).then(() => {
988
+ if (operation === "sync")
989
+ this.backend.release(a);
990
+ return this.finishResult(session, id, operation, operation === "sync" ? 0 : undefined);
991
+ }, (error) => {
992
+ if (operation === "sync")
993
+ this.backend.release(a);
994
+ throw error;
995
+ });
978
996
  }
979
997
  if (operation === "resolve" && session.socketScope && this.backend instanceof MemoryBackend) {
980
998
  const result = this.backend.fs.resolveSocket(a, b, c === true);
981
999
  return this.finishResult(session, id, operation, result, args);
982
1000
  }
983
- const result = this.backend.execute(operation, args, data);
1001
+ const isCancelled = () => {
1002
+ const pending = session.pending.get(id);
1003
+ return !pending || sessionRevoked(session) || !this.sessions.has(session) || requestCancelled(pending);
1004
+ };
1005
+ const result = this.backend.execute(operation, args, data, isCancelled);
984
1006
  if (result instanceof Promise)
985
1007
  return this.trackRequestWork(session, result).then((value) => this.finishResult(session, id, operation, value, args));
986
1008
  return this.finishResult(session, id, operation, result, args);
@@ -1 +1 @@
1
- {"commit":"da522cacff05cf6f18e820967a2e0f52d2f19680","buildToolsSha256":"b617652c1601f8722bb85c3a688a1fca4985b53f2c2066c10c76c2e693081137","optimizerSourceSha256":"34c4a040f3cf639f039823880822c6541c384c9b4eaa116d27dda8d9cb5c9f9e"}
1
+ {"commit":"72849910ef1260a1e27ec37e6b3a8e0371f71de3","buildToolsSha256":"b617652c1601f8722bb85c3a688a1fca4985b53f2c2066c10c76c2e693081137","optimizerSourceSha256":"34c4a040f3cf639f039823880822c6541c384c9b4eaa116d27dda8d9cb5c9f9e"}
package/fs/backend.ts CHANGED
@@ -23,7 +23,12 @@ import { SharedFilesystemState, type SharedSegment } from "./shared.js";
23
23
 
24
24
  /** Storage boundary. 3b can add asynchronous loading/commit without changing guest transport. */
25
25
  export interface FilesystemBackend {
26
- execute(operation: string, args: any[], data: Uint8Array): unknown | Promise<unknown>;
26
+ execute(
27
+ operation: string,
28
+ args: any[],
29
+ data: Uint8Array,
30
+ cancelled?: () => boolean,
31
+ ): unknown | Promise<unknown>;
27
32
  retain(handle: FileHandle): void;
28
33
  release(handle: FileHandle): void;
29
34
  resources?(): Record<string, number>;