Skip to content

Commit a8ca596

Browse files
sirtimidclaude
andcommitted
feat(cli): add --timeout flag to daemon exec
Long-running RPC calls (e.g. on-chain transaction confirmation) can exceed the default 30s socket read timeout. Add a --timeout option (in seconds) so callers can raise the limit per invocation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a956a06 commit a8ca596

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

packages/cli/src/app.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ const yargsInstance = yargs(hideBin(process.argv))
255255
'$0 daemon exec executeDBQuery \'{"sql":"SELECT * FROM kv LIMIT 5"}\'',
256256
'Run a SQL query',
257257
)
258+
.option('timeout', {
259+
describe: 'Read timeout in seconds (default: 30)',
260+
type: 'number',
261+
})
258262
.example(
259263
'$0 daemon exec terminateVat \'{"vatId":"v1"}\'',
260264
'Terminate a vat',
@@ -268,7 +272,13 @@ const yargsInstance = yargs(hideBin(process.argv))
268272
execArgs.push(String(args['params-json']));
269273
}
270274
await ensureDaemon(socketPath);
271-
await handleDaemonExec(execArgs, socketPath);
275+
await handleDaemonExec(
276+
execArgs,
277+
socketPath,
278+
typeof args.timeout === 'number'
279+
? { timeoutMs: args.timeout * 1000 }
280+
: {},
281+
);
272282
},
273283
)
274284
.command(

packages/cli/src/commands/daemon.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,13 @@ export async function handleDaemonBegone(socketPath: string): Promise<void> {
165165
*
166166
* @param args - Positional arguments: [method, params-json].
167167
* @param socketPath - The daemon socket path.
168+
* @param options - Additional options.
169+
* @param options.timeoutMs - Read timeout in milliseconds.
168170
*/
169171
export async function handleDaemonExec(
170172
args: string[],
171173
socketPath: string,
174+
{ timeoutMs }: { timeoutMs?: number } = {},
172175
): Promise<void> {
173176
const method = args[0] ?? 'getStatus';
174177
const rawParams = args[1];
@@ -194,7 +197,12 @@ export async function handleDaemonExec(
194197
}
195198
}
196199

197-
const response = await sendCommand({ socketPath, method, params });
200+
const response = await sendCommand({
201+
socketPath,
202+
method,
203+
params,
204+
...(timeoutMs === undefined ? {} : { timeoutMs }),
205+
});
198206

199207
if (isJsonRpcFailure(response)) {
200208
process.stderr.write(

0 commit comments

Comments
 (0)