larkin 0.5.9 → 0.5.10
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.
|
@@ -93,11 +93,11 @@ class PiRpcClient {
|
|
|
93
93
|
throw new Error("stdin is unavailable");
|
|
94
94
|
this.process.stdin.write(`${JSON.stringify({ id, type: command, ...fields })}\n`, (error) => {
|
|
95
95
|
if (error)
|
|
96
|
-
this.
|
|
96
|
+
this.failWrite(command, error);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
|
100
|
-
this.
|
|
100
|
+
this.failWrite(command, error);
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
}
|
|
@@ -214,6 +214,24 @@ class PiRpcClient {
|
|
|
214
214
|
protocolFailure(detail) {
|
|
215
215
|
this.fail(new Error(`Pi RPC protocol error: ${detail}`), true);
|
|
216
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* A failed write matters less than why the process is gone: a spawn failure or
|
|
219
|
+
* an early exit explains it, and that verdict is queued on the next tick. Defer
|
|
220
|
+
* the write error by a single turn (next tick runs before the check phase, so a
|
|
221
|
+
* real spawn/exit verdict always wins) and report it only if no verdict arrives.
|
|
222
|
+
* No arbitration timer; concurrent write failures collapse into the client's
|
|
223
|
+
* single first-error terminal state via `fail`'s idempotence.
|
|
224
|
+
*/
|
|
225
|
+
failWrite(command, error) {
|
|
226
|
+
if (this.failed)
|
|
227
|
+
return;
|
|
228
|
+
const message = `Pi RPC ${command} write failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
229
|
+
setImmediate(() => {
|
|
230
|
+
if (this.failed)
|
|
231
|
+
return;
|
|
232
|
+
this.fail(new Error(message), true);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
217
235
|
fail(error, terminate) {
|
|
218
236
|
if (this.failed)
|
|
219
237
|
return;
|
|
@@ -90,11 +90,11 @@ export class PiRpcClient {
|
|
|
90
90
|
throw new Error("stdin is unavailable");
|
|
91
91
|
this.process.stdin.write(`${JSON.stringify({ id, type: command, ...fields })}\n`, (error) => {
|
|
92
92
|
if (error)
|
|
93
|
-
this.
|
|
93
|
+
this.failWrite(command, error);
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
|
-
this.
|
|
97
|
+
this.failWrite(command, error);
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
}
|
|
@@ -211,6 +211,24 @@ export class PiRpcClient {
|
|
|
211
211
|
protocolFailure(detail) {
|
|
212
212
|
this.fail(new Error(`Pi RPC protocol error: ${detail}`), true);
|
|
213
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* A failed write matters less than why the process is gone: a spawn failure or
|
|
216
|
+
* an early exit explains it, and that verdict is queued on the next tick. Defer
|
|
217
|
+
* the write error by a single turn (next tick runs before the check phase, so a
|
|
218
|
+
* real spawn/exit verdict always wins) and report it only if no verdict arrives.
|
|
219
|
+
* No arbitration timer; concurrent write failures collapse into the client's
|
|
220
|
+
* single first-error terminal state via `fail`'s idempotence.
|
|
221
|
+
*/
|
|
222
|
+
failWrite(command, error) {
|
|
223
|
+
if (this.failed)
|
|
224
|
+
return;
|
|
225
|
+
const message = `Pi RPC ${command} write failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
226
|
+
setImmediate(() => {
|
|
227
|
+
if (this.failed)
|
|
228
|
+
return;
|
|
229
|
+
this.fail(new Error(message), true);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
214
232
|
fail(error, terminate) {
|
|
215
233
|
if (this.failed)
|
|
216
234
|
return;
|