toeverything/AFFiNE · error · AuthSessionError
AUTH_OPERATION_CANCELLED
AUTH_OPERATION_CANCELLED
Error message
AUTH_OPERATION_CANCELLED
What it means
persistPending aborts with AuthSessionError('AUTH_OPERATION_CANCELLED') when the storage mutation completed but the pending epoch no longer matches the broker's current epoch, meaning a newer auth operation superseded this one and its result must be discarded.
Source
Thrown at packages/common/auth/src/token-broker.ts:297
status: 'offline-authenticated',
session: this.toSnapshot(current),
code: classified.code,
});
}
throw classified;
}
}
private async persistPending() {
const pending = this.pending;
if (!pending) throw new AuthSessionError('AUTH_SESSION_EMPTY', false);
try {
await this.mutateStorage(() => this.storage.save(pending.pair));
} catch {
throw new AuthSessionError('AUTH_TOKEN_STORAGE_UNAVAILABLE', true);
}
if (pending.epoch !== this.mutationEpoch) {
throw new AuthSessionError('AUTH_OPERATION_CANCELLED', true);
}
this.pending = null;
this.pair = pending.pair;
this.publish({
status: 'authenticated',
session: this.toSnapshot(pending.pair),
});
return pending.pair;
}
private async mutateStorage<T>(operation: () => Promise<T>) {
const result = this.storageMutation.then(operation, operation);
this.storageMutation = result.then(
() => {},
() => {}
);
return await result;
}View on GitHub (pinned to b4c8548c09)
Solutions
- Retry the sign-in flow; the previous attempt was cancelled before completion.
- Do not close the authentication window or navigate away during the flow.
- If the user intentionally cancelled, no action is needed.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/common/auth/src/token-broker.ts:297 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/42d750308c89c159.
Report an issue: GitHub.