@jini-ai/sidecar 0.6.12 → 0.6.15-rc.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @jini-ai/sidecar
2
2
 
3
+ ## 0.6.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [7479159]
8
+ - Updated dependencies [c31264d]
9
+ - Updated dependencies [0728914]
10
+ - Updated dependencies [6ecbdb2]
11
+ - Updated dependencies [63bacc5]
12
+ - @jini-ai/core@0.6.13
13
+
3
14
  ## 0.6.12
4
15
 
5
16
  ### Patch Changes
@@ -60,7 +60,8 @@ export declare function createJsonIpcServer({ handler, socketPath, }: {
60
60
  }): Promise<JsonIpcServerHandle>;
61
61
  /**
62
62
  * Send one newline-delimited JSON request over a unix socket / named pipe and
63
- * resolve with the server's `result`, rejecting on error response or timeout.
63
+ * resolve with the server's `result`, rejecting on error response, malformed JSON,
64
+ * connection error, close before a complete reply, or timeout.
64
65
  * @returns The server's `result` payload.
65
66
  */
66
67
  export declare function requestJsonIpc<T = any>({ socketPath, payload }: {
package/dist/json-ipc.js CHANGED
@@ -363,7 +363,8 @@ export async function createJsonIpcServer({ handler, socketPath, }, { maxFrameBy
363
363
  }
364
364
  /**
365
365
  * Send one newline-delimited JSON request over a unix socket / named pipe and
366
- * resolve with the server's `result`, rejecting on error response or timeout.
366
+ * resolve with the server's `result`, rejecting on error response, malformed JSON,
367
+ * connection error, close before a complete reply, or timeout.
367
368
  * @returns The server's `result` payload.
368
369
  */
369
370
  export async function requestJsonIpc({ socketPath, payload }, { timeoutMs = 1500 } = {}) {
@@ -444,7 +445,15 @@ export async function requestJsonIpc({ socketPath, payload }, { timeoutMs = 1500
444
445
  return;
445
446
  socket.end();
446
447
  settle(() => {
447
- const response = JSON.parse(buffer.slice(0, newlineIndex));
448
+ let response;
449
+ try {
450
+ response = JSON.parse(buffer.slice(0, newlineIndex));
451
+ }
452
+ catch (error) {
453
+ // Event-handler throws cannot reject the request promise.
454
+ rejectRequest(error);
455
+ return;
456
+ }
448
457
  if (!response.ok) {
449
458
  traceJsonIpc("client.response_error", {
450
459
  durationMs: jsonIpcTraceDurationMs(startedAt),
@@ -453,12 +462,7 @@ export async function requestJsonIpc({ socketPath, payload }, { timeoutMs = 1500
453
462
  socketPath,
454
463
  traceId,
455
464
  });
456
- const rejection = new Error(response.error?.message ?? "IPC request failed");
457
- if (response.error?.code !== undefined)
458
- rejection.code = response.error.code;
459
- if (response.error?.requestId !== undefined)
460
- rejection.requestId = response.error.requestId;
461
- rejectRequest(rejection);
465
+ rejectRequest(ipcResponseError(response.error));
462
466
  return;
463
467
  }
464
468
  traceJsonIpc("client.response_success", {
@@ -490,7 +494,16 @@ export async function requestJsonIpc({ socketPath, payload }, { timeoutMs = 1500
490
494
  socketPath,
491
495
  traceId,
492
496
  });
497
+ settle(() => rejectRequest(new Error(`IPC connection closed before a complete response: ${socketPath}`)));
493
498
  });
494
499
  });
495
500
  }
501
+ function ipcResponseError(error) {
502
+ const rejection = new Error(error?.message ?? "IPC request failed");
503
+ if (error?.code !== undefined)
504
+ rejection.code = error.code;
505
+ if (error?.requestId !== undefined)
506
+ rejection.requestId = error.requestId;
507
+ return rejection;
508
+ }
496
509
  //# sourceMappingURL=json-ipc.js.map
@@ -17,8 +17,9 @@ export function createSupervisorRegistry({ registryPath }) {
17
17
  };
18
18
  }
19
19
  function relayProcessOutput({ stream, sink }, _options = {}) {
20
+ // Sinks belong to the host and must survive EOF from a child that may respawn.
20
21
  if (sink !== undefined)
21
- stream?.pipe(sink);
22
+ stream?.pipe(sink, { end: false });
22
23
  else
23
24
  stream?.resume();
24
25
  }
@@ -38,6 +38,8 @@ export function createDaemonSupervisor(deps, options = {}) {
38
38
  function failed(error) {
39
39
  state.stopping = false;
40
40
  state.replaceAfterExit = false;
41
+ // A failed replacement must not suppress recovery from a later crash.
42
+ state.deliberate = false;
41
43
  if (current === state)
42
44
  reportFailure(`failed to stop daemon: ${String(error)}`);
43
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/sidecar",
3
- "version": "0.6.12",
3
+ "version": "0.6.15-rc.2",
4
4
  "description": "Sidecar process runtime: JSON-IPC server and client, IPC path validation, namespace/runtime path resolution, port allocation, launch bootstrap, and a local daemon registry.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -63,14 +63,14 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@vitest/coverage-v8": "^2.1.9",
66
- "@jini-ai/core": "0.6.12",
67
- "@jini-ai/platform": "0.6.12"
66
+ "@jini-ai/core": "0.6.15-rc.2",
67
+ "@jini-ai/platform": "0.6.15-rc.2"
68
68
  },
69
69
  "dependencies": {
70
- "@jini-ai/core": "^0.6.12"
70
+ "@jini-ai/core": "^0.6.15-rc.2"
71
71
  },
72
72
  "peerDependencies": {
73
- "@jini-ai/platform": "^0.6.10"
73
+ "@jini-ai/platform": "^0.6.15-rc.2"
74
74
  },
75
75
  "peerDependenciesMeta": {
76
76
  "@jini-ai/platform": {