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
-4
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* @file Alice buys a widget from Bob, over ERTP in the canister.
|
||||
*/
|
||||
const HELP = `usage: shop.mjs HOST CANISTER_ID KEY_FILE STEP
|
||||
const HELP = `usage: shop.mjs HOST CANISTER_ID KEY_FILE STEP [--abandon-all]
|
||||
|
||||
Each STEP runs as the principal whose key is in KEY_FILE (made if missing):
|
||||
|
||||
@@ -14,7 +14,9 @@ Each STEP runs as the principal whose key is in KEY_FILE (made if missing):
|
||||
purse at home as "closet"
|
||||
balances show each purse kept at home
|
||||
|
||||
Run mint and buy as Alice, open as Bob.`;
|
||||
Run mint and buy as Alice, open as Bob. A principal has one session at a
|
||||
time; --abandon-all first ends the one a previous run left open, breaking
|
||||
everything that lived only in it.`;
|
||||
|
||||
import { connect } from './connect.js';
|
||||
|
||||
@@ -86,13 +88,15 @@ const steps = {
|
||||
},
|
||||
};
|
||||
|
||||
const main = async ([host, canisterId, keyFile, step]) => {
|
||||
const main = async argv => {
|
||||
const abandonAll = argv.includes('--abandon-all');
|
||||
const [host, canisterId, keyFile, step] = argv.filter(arg => arg !== '--abandon-all');
|
||||
if (!Object.hasOwn(steps, step ?? '')) {
|
||||
console.error(HELP);
|
||||
process.exitCode = 2;
|
||||
return;
|
||||
}
|
||||
const peer = await connect(host, canisterId, keyFile);
|
||||
const peer = await connect(host, canisterId, keyFile, { abandonAll });
|
||||
await steps[step](peer, peer.fetch('home'), peer.fetch('board'));
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user