feat: abandonAll, explicitly, instead of replacing a session on start
Ending a session breaks every reference and pending answer that lives only in it, so it takes its own update method rather than happening as a side effect of start. A second start traps again; the clients take --abandon-all to end the session a previous run left open. Generated-by: Claude Code (claude-opus-5-5)
This commit is contained in:
1 parent
9db91b1b9c
commit
6c437ec2f1
9 files changed
+73
-26
No files matched your search
+8
-5
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* @file Call the Counter canister over OCapN.
|
||||
*/
|
||||
const HELP = `usage: counter.mjs HOST CANISTER_ID KEY_FILE init NAME
|
||||
counter.mjs HOST CANISTER_ID KEY_FILE use NAME [VERB...]
|
||||
const HELP = `usage: counter.mjs HOST CANISTER_ID KEY_FILE init NAME [--abandon-all]
|
||||
counter.mjs HOST CANISTER_ID KEY_FILE use NAME [VERB...] [--abandon-all]
|
||||
|
||||
Open a CapTP session to the canister as the principal whose Ed25519 seed is
|
||||
in KEY_FILE (32 bytes, made if missing), then:
|
||||
@@ -14,18 +14,21 @@ in KEY_FILE (32 bytes, made if missing), then:
|
||||
(incr, decr, value; default: incr value)
|
||||
|
||||
Each run's sends are pipelined: one update call after the handshake, plus
|
||||
one for init. HOST is the replica, e.g. http://127.0.0.1:4960, or
|
||||
one for init. A principal has one session at a time; --abandon-all first
|
||||
ends the one a previous run left open. HOST is the replica, e.g. http://127.0.0.1:4960, or
|
||||
https://icp-api.io.`;
|
||||
|
||||
import { connect } from './connect.js';
|
||||
|
||||
const main = async ([host, canisterId, keyFile, command, name, ...verbs]) => {
|
||||
const main = async argv => {
|
||||
const abandonAll = argv.includes('--abandon-all');
|
||||
const [host, canisterId, keyFile, command, name, ...verbs] = argv.filter(arg => arg !== '--abandon-all');
|
||||
if (!name || !['init', 'use'].includes(command)) {
|
||||
console.error(HELP);
|
||||
process.exitCode = 2;
|
||||
return;
|
||||
}
|
||||
const peer = await connect(host, canisterId, keyFile);
|
||||
const peer = await connect(host, canisterId, keyFile, { abandonAll });
|
||||
console.log('session open');
|
||||
const home = peer.fetch('home');
|
||||
/** Send each verb without waiting, then print each answer. */
|
||||
|
||||
Reference in new issue
Block a user