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
+9
-1
@@ -12,6 +12,7 @@ const idlFactory = ({ IDL }) => {
|
||||
return IDL.Service({
|
||||
start: IDL.Func([Frames], [Frames], []),
|
||||
deliver: IDL.Func([Frames], [Frames], []),
|
||||
abandonAll: IDL.Func([], [], []),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -34,8 +35,11 @@ const keySeed = async path => {
|
||||
* @param {string} host the replica, e.g. https://icp-api.io
|
||||
* @param {string} canisterId
|
||||
* @param {string} keyFile
|
||||
* @param {object} [opts]
|
||||
* @param {boolean} [opts.abandonAll] first end the principal's open session,
|
||||
* breaking every reference and pending answer that lives only in it
|
||||
*/
|
||||
export const connect = async (host, canisterId, keyFile) => {
|
||||
export const connect = async (host, canisterId, keyFile, { abandonAll = false } = {}) => {
|
||||
const { hostname } = new URL(host);
|
||||
const agent = await HttpAgent.create({
|
||||
host,
|
||||
@@ -44,6 +48,10 @@ export const connect = async (host, canisterId, keyFile) => {
|
||||
shouldFetchRootKey: hostname === '127.0.0.1' || hostname === 'localhost',
|
||||
});
|
||||
const actor = Actor.createActor(idlFactory, { agent, canisterId });
|
||||
if (abandonAll) {
|
||||
await actor.abandonAll();
|
||||
console.error(' abandoned the previous session');
|
||||
}
|
||||
const carry = async (method, frames) => {
|
||||
const t0 = performance.now();
|
||||
const reply = await actor[method](frames);
|
||||
|
||||
Reference in new issue
Block a user