@fantastic.dev/better-stripe 0.94.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operationJournal.js +10 -0
- package/dist/client/billing/renewalAttach/internal/operationJournal.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +40 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +13 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +43 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts +32 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js +105 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.js +59 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.d.ts +11 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.js +121 -0
- package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.js +16 -0
- package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.js.map +1 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +24 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/operationJournal.ts +12 -0
- package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +59 -0
- package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +58 -0
- package/src/client/billing/renewalAttach/internal/producer/lineageAuthority.ts +161 -0
- package/src/client/billing/renewalAttach/internal/producer/ownedAwaitFactory.ts +54 -0
- package/src/client/billing/renewalAttach/internal/producer/ownerFactory.ts +124 -0
- package/src/client/billing/renewalAttach/internal/producer/producerOwner.integration.test.ts +457 -0
- package/src/client/billing/renewalAttach/internal/producer/stockDelegateFactory.ts +23 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialDeclarations.ts +5 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +80 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { mintInitialLineage, readInitialLineage } from "./lineageAuthority.js";
|
|
2
|
+
import { ownerForInitialLineage, type InitialOwner } from "./ownerFactory.js";
|
|
3
|
+
import { ownedAwaitForInitialLineage } from "./ownedAwaitFactory.js";
|
|
4
|
+
import { stockDelegateForInitialLineage } from "./stockDelegateFactory.js";
|
|
5
|
+
import type { createClassActionOperationJournal } from "../operationJournal.js";
|
|
6
|
+
|
|
7
|
+
export type InitialInvocationCore = Readonly<{
|
|
8
|
+
owner: InitialOwner;
|
|
9
|
+
basisJSON: string;
|
|
10
|
+
delegate: ReturnType<typeof stockDelegateForInitialLineage>;
|
|
11
|
+
owned<T>(work: () => T | PromiseLike<T>): Promise<T>;
|
|
12
|
+
operationalAuthority: false;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
/** Node-only private construction. Does not admit an operational runtime profile. */
|
|
16
|
+
export async function captureInitialInvocationCore(
|
|
17
|
+
call: unknown,
|
|
18
|
+
journal: Awaited<ReturnType<typeof createClassActionOperationJournal>>,
|
|
19
|
+
): Promise<InitialInvocationCore> {
|
|
20
|
+
const token = mintInitialLineage(call, journal, arguments.length);
|
|
21
|
+
const lineage = readInitialLineage(token);
|
|
22
|
+
const owner = ownerForInitialLineage(token);
|
|
23
|
+
try {
|
|
24
|
+
const owned = ownedAwaitForInitialLineage(token);
|
|
25
|
+
const reservation = lineage.reservation;
|
|
26
|
+
if (!("timingPolicyJSON" in reservation))
|
|
27
|
+
throw Error("INITIAL_LINEAGE_UNBOUND");
|
|
28
|
+
const bound = await owned(() =>
|
|
29
|
+
journal.bindInitialBasis({
|
|
30
|
+
attemptId: reservation.attemptId,
|
|
31
|
+
policyJSON: reservation.timingPolicyJSON,
|
|
32
|
+
basisJSON: lineage.basisJSON,
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
if (
|
|
36
|
+
bound.status !== "bound" ||
|
|
37
|
+
bound.operationId !== reservation.operationId ||
|
|
38
|
+
bound.initialBasis.attemptId !== reservation.attemptId ||
|
|
39
|
+
bound.initialBasis.sourcePayloadId !== reservation.payloadId ||
|
|
40
|
+
bound.initialBasis.basisJSON !== lineage.basisJSON ||
|
|
41
|
+
bound.initialBasis.policyJSON !== reservation.timingPolicyJSON ||
|
|
42
|
+
bound.initialBasis.stage !== "attach" ||
|
|
43
|
+
bound.initialBasis.version !== 1
|
|
44
|
+
)
|
|
45
|
+
throw Error("INITIAL_LINEAGE_UNBOUND");
|
|
46
|
+
owner.check();
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
owner,
|
|
49
|
+
basisJSON: lineage.basisJSON,
|
|
50
|
+
owned,
|
|
51
|
+
delegate: stockDelegateForInitialLineage(token),
|
|
52
|
+
operationalAuthority: false,
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
owner.retire();
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import { consumeInitialClassReservation } from "../operationJournal.js";
|
|
4
|
+
import { captureInitialJournalSelection } from "./classOwnedActionRoot.js";
|
|
5
|
+
import { canonicalInitialBasis } from "../../../../../shared/renewalOperationJournal.js";
|
|
6
|
+
|
|
7
|
+
const method = Object.getOwnPropertyDescriptor(
|
|
8
|
+
Stripe.prototype,
|
|
9
|
+
"rawRequest",
|
|
10
|
+
)?.value;
|
|
11
|
+
const u64 = 18446744073709551615n;
|
|
12
|
+
const timerLimit = 2147483647;
|
|
13
|
+
function stop(): never {
|
|
14
|
+
throw Error("INITIAL_LINEAGE_UNBOUND");
|
|
15
|
+
}
|
|
16
|
+
const ms = (value: number) => Number.isSafeInteger(value) && value >= 0;
|
|
17
|
+
|
|
18
|
+
// Only this module mints identities. Retained journal DATA cannot construct one.
|
|
19
|
+
class InitialLineage {}
|
|
20
|
+
type Lineage = Readonly<{
|
|
21
|
+
reservation: ReturnType<typeof consumeInitialClassReservation>["reservation"];
|
|
22
|
+
selection: ReturnType<typeof captureInitialJournalSelection>;
|
|
23
|
+
client: Stripe;
|
|
24
|
+
method: Stripe["rawRequest"];
|
|
25
|
+
basis: Readonly<{
|
|
26
|
+
startWallMs: number;
|
|
27
|
+
startNs: bigint;
|
|
28
|
+
workEndWallMs: number;
|
|
29
|
+
workEndNs: bigint;
|
|
30
|
+
endWallMs: number;
|
|
31
|
+
endNs: bigint;
|
|
32
|
+
}>;
|
|
33
|
+
basisJSON: string;
|
|
34
|
+
initialHighNs: bigint;
|
|
35
|
+
policy: Readonly<{
|
|
36
|
+
firstDispatchedAt: number;
|
|
37
|
+
periodStart: number;
|
|
38
|
+
periodEnd: number;
|
|
39
|
+
}>;
|
|
40
|
+
wall: () => number;
|
|
41
|
+
monotonic: () => bigint;
|
|
42
|
+
}>;
|
|
43
|
+
const lineages = new WeakMap<object, Lineage>();
|
|
44
|
+
|
|
45
|
+
/** Consumes original CAS custody before any selector, runtime clock or Owner. */
|
|
46
|
+
export function mintInitialLineage(
|
|
47
|
+
call: unknown,
|
|
48
|
+
journal: unknown,
|
|
49
|
+
arity: number,
|
|
50
|
+
): object {
|
|
51
|
+
const { reservation, binding } = consumeInitialClassReservation(
|
|
52
|
+
call,
|
|
53
|
+
journal,
|
|
54
|
+
);
|
|
55
|
+
if (arity !== 2) stop();
|
|
56
|
+
if (
|
|
57
|
+
!("recordVersion" in reservation) ||
|
|
58
|
+
reservation.recordVersion !== 2 ||
|
|
59
|
+
reservation.stage !== "attach" ||
|
|
60
|
+
!("timingPolicyJSON" in reservation)
|
|
61
|
+
)
|
|
62
|
+
stop();
|
|
63
|
+
const selection = captureInitialJournalSelection(
|
|
64
|
+
binding,
|
|
65
|
+
reservation.apiVersion,
|
|
66
|
+
);
|
|
67
|
+
const client = selection.select();
|
|
68
|
+
if (
|
|
69
|
+
!client ||
|
|
70
|
+
typeof client !== "object" ||
|
|
71
|
+
types.isProxy(client) ||
|
|
72
|
+
Object.getPrototypeOf(client) !== Stripe.prototype ||
|
|
73
|
+
Object.prototype.hasOwnProperty.call(client, "rawRequest") ||
|
|
74
|
+
typeof method !== "function" ||
|
|
75
|
+
Object.getOwnPropertyDescriptor(Stripe.prototype, "rawRequest")?.value !==
|
|
76
|
+
method
|
|
77
|
+
)
|
|
78
|
+
stop();
|
|
79
|
+
selection.check();
|
|
80
|
+
const policy = JSON.parse(reservation.timingPolicyJSON) as {
|
|
81
|
+
firstDispatchedAt: number;
|
|
82
|
+
periodStart: number;
|
|
83
|
+
periodEnd: number;
|
|
84
|
+
workEndWallMs: number;
|
|
85
|
+
endWallMs: number;
|
|
86
|
+
};
|
|
87
|
+
const wall = Date.now;
|
|
88
|
+
const monotonic = process.hrtime.bigint;
|
|
89
|
+
const lo = monotonic();
|
|
90
|
+
const startWallMs = wall();
|
|
91
|
+
const hi = monotonic();
|
|
92
|
+
if (
|
|
93
|
+
!ms(startWallMs) ||
|
|
94
|
+
lo < 0n ||
|
|
95
|
+
hi < lo ||
|
|
96
|
+
hi > u64 ||
|
|
97
|
+
hi - lo > 1000000n ||
|
|
98
|
+
startWallMs >= policy.workEndWallMs ||
|
|
99
|
+
policy.endWallMs - startWallMs > timerLimit
|
|
100
|
+
)
|
|
101
|
+
stop();
|
|
102
|
+
const basis = Object.freeze({
|
|
103
|
+
startWallMs,
|
|
104
|
+
startNs: lo,
|
|
105
|
+
workEndWallMs: policy.workEndWallMs,
|
|
106
|
+
workEndNs:
|
|
107
|
+
lo + (BigInt(policy.workEndWallMs) - BigInt(startWallMs)) * 1000000n,
|
|
108
|
+
endWallMs: policy.endWallMs,
|
|
109
|
+
endNs: lo + (BigInt(policy.endWallMs) - BigInt(startWallMs)) * 1000000n,
|
|
110
|
+
});
|
|
111
|
+
if (basis.endNs > u64) stop();
|
|
112
|
+
const rawBasisJSON = JSON.stringify({
|
|
113
|
+
startWallMs,
|
|
114
|
+
startNsDecimal: lo.toString(),
|
|
115
|
+
workEndWallMs: basis.workEndWallMs,
|
|
116
|
+
workEndNsDecimal: basis.workEndNs.toString(),
|
|
117
|
+
endWallMs: basis.endWallMs,
|
|
118
|
+
endNsDecimal: basis.endNs.toString(),
|
|
119
|
+
});
|
|
120
|
+
const { basisJSON } = canonicalInitialBasis(
|
|
121
|
+
reservation.timingPolicyJSON,
|
|
122
|
+
rawBasisJSON,
|
|
123
|
+
);
|
|
124
|
+
selection.check();
|
|
125
|
+
const token = Object.freeze(new InitialLineage());
|
|
126
|
+
lineages.set(
|
|
127
|
+
token,
|
|
128
|
+
Object.freeze({
|
|
129
|
+
reservation,
|
|
130
|
+
selection,
|
|
131
|
+
client: client as Stripe,
|
|
132
|
+
method: method as Stripe["rawRequest"],
|
|
133
|
+
basis,
|
|
134
|
+
basisJSON,
|
|
135
|
+
initialHighNs: hi,
|
|
136
|
+
policy: Object.freeze({
|
|
137
|
+
firstDispatchedAt: policy.firstDispatchedAt,
|
|
138
|
+
periodStart: policy.periodStart,
|
|
139
|
+
periodEnd: policy.periodEnd,
|
|
140
|
+
}),
|
|
141
|
+
wall,
|
|
142
|
+
monotonic,
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
145
|
+
return token;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Opaque private identity required by every invocation kernel. */
|
|
149
|
+
export function readInitialLineage(token: object): Lineage {
|
|
150
|
+
const lineage = lineages.get(token);
|
|
151
|
+
if (!lineage) stop();
|
|
152
|
+
lineage.selection.check();
|
|
153
|
+
if (
|
|
154
|
+
Object.getOwnPropertyDescriptor(Stripe.prototype, "rawRequest")?.value !==
|
|
155
|
+
lineage.method ||
|
|
156
|
+
Object.prototype.hasOwnProperty.call(lineage.client, "rawRequest") ||
|
|
157
|
+
Object.getPrototypeOf(lineage.client) !== Stripe.prototype
|
|
158
|
+
)
|
|
159
|
+
stop();
|
|
160
|
+
return lineage;
|
|
161
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ownerForInitialLineage } from "./ownerFactory.js";
|
|
2
|
+
|
|
3
|
+
/** Each continuation retains its own canonical Owner, with no ambient switch. */
|
|
4
|
+
export function ownedAwaitForInitialLineage(token: object) {
|
|
5
|
+
const owner = ownerForInitialLineage(token);
|
|
6
|
+
return function owned<T>(work: () => T | PromiseLike<T>): Promise<T> {
|
|
7
|
+
owner.check();
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
let settled = false;
|
|
10
|
+
let remove: (() => void) | null = null;
|
|
11
|
+
function finish(ok: boolean, value: unknown) {
|
|
12
|
+
if (settled) return;
|
|
13
|
+
settled = true;
|
|
14
|
+
remove?.();
|
|
15
|
+
if (ok) resolve(value as T);
|
|
16
|
+
else reject(value);
|
|
17
|
+
}
|
|
18
|
+
const retire = () => finish(false, Error("INITIAL_OWNER_STOP"));
|
|
19
|
+
remove = owner.subscribe(retire);
|
|
20
|
+
if (settled) {
|
|
21
|
+
remove();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let pending: T | PromiseLike<T>;
|
|
25
|
+
try {
|
|
26
|
+
owner.check();
|
|
27
|
+
pending = work();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
finish(false, error);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
void Promise.resolve(pending).then(
|
|
33
|
+
(value) => {
|
|
34
|
+
if (settled) return;
|
|
35
|
+
try {
|
|
36
|
+
owner.check();
|
|
37
|
+
finish(true, value);
|
|
38
|
+
} catch {
|
|
39
|
+
retire();
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
(error: unknown) => {
|
|
43
|
+
if (settled) return;
|
|
44
|
+
try {
|
|
45
|
+
owner.check();
|
|
46
|
+
finish(false, error);
|
|
47
|
+
} catch {
|
|
48
|
+
retire();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { readInitialLineage } from "./lineageAuthority.js";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import type { OriginalBasis, OriginalSample } from "../originalOwner.js";
|
|
4
|
+
|
|
5
|
+
export type InitialOwner = Readonly<{
|
|
6
|
+
basis: Readonly<OriginalBasis>;
|
|
7
|
+
check(): Readonly<OriginalSample>;
|
|
8
|
+
sample(): Readonly<OriginalSample>;
|
|
9
|
+
subscribe(fn: () => void): () => void;
|
|
10
|
+
retire(): void;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
const owners = new WeakMap<object, InitialOwner>();
|
|
14
|
+
function stop(): never {
|
|
15
|
+
throw Error("INITIAL_OWNER_STOP");
|
|
16
|
+
}
|
|
17
|
+
/** One canonical, independently retired Owner per original private lineage. */
|
|
18
|
+
export function ownerForInitialLineage(token: object): InitialOwner {
|
|
19
|
+
const existing = owners.get(token);
|
|
20
|
+
if (existing) return existing;
|
|
21
|
+
const lineage = readInitialLineage(token);
|
|
22
|
+
const { basis, policy } = lineage;
|
|
23
|
+
let closed = false;
|
|
24
|
+
let checking = false;
|
|
25
|
+
let last: Readonly<OriginalSample> | null = null;
|
|
26
|
+
const listeners = new Set<{ fn: () => void; active: boolean }>();
|
|
27
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
28
|
+
function retire() {
|
|
29
|
+
if (closed) return;
|
|
30
|
+
closed = true;
|
|
31
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
32
|
+
const active = [...listeners];
|
|
33
|
+
listeners.clear();
|
|
34
|
+
for (const listener of active) {
|
|
35
|
+
if (!listener.active) continue;
|
|
36
|
+
listener.active = false;
|
|
37
|
+
try {
|
|
38
|
+
Reflect.apply(listener.fn, undefined, []);
|
|
39
|
+
} catch {
|
|
40
|
+
/* Retirement cannot be reversed by a waiter. */
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function check(): Readonly<OriginalSample> {
|
|
45
|
+
if (closed || checking) {
|
|
46
|
+
retire();
|
|
47
|
+
stop();
|
|
48
|
+
}
|
|
49
|
+
checking = true;
|
|
50
|
+
try {
|
|
51
|
+
if (readInitialLineage(token) !== lineage) stop();
|
|
52
|
+
const wallMs = lineage.wall();
|
|
53
|
+
const ns = lineage.monotonic();
|
|
54
|
+
const nowSeconds = Math.floor(wallMs / 1000);
|
|
55
|
+
if (
|
|
56
|
+
!Number.isSafeInteger(wallMs) ||
|
|
57
|
+
wallMs < basis.startWallMs ||
|
|
58
|
+
wallMs >= basis.workEndWallMs ||
|
|
59
|
+
wallMs >= basis.endWallMs ||
|
|
60
|
+
ns < lineage.initialHighNs ||
|
|
61
|
+
ns >= basis.workEndNs ||
|
|
62
|
+
ns >= basis.endNs ||
|
|
63
|
+
(last && (wallMs < last.wallMs || ns < last.ns)) ||
|
|
64
|
+
nowSeconds < policy.firstDispatchedAt ||
|
|
65
|
+
nowSeconds - policy.firstDispatchedAt >= 86400 ||
|
|
66
|
+
nowSeconds < policy.periodStart ||
|
|
67
|
+
nowSeconds >= policy.periodEnd ||
|
|
68
|
+
closed
|
|
69
|
+
)
|
|
70
|
+
stop();
|
|
71
|
+
last = Object.freeze({ wallMs, ns, nowSeconds, retired: false });
|
|
72
|
+
return last;
|
|
73
|
+
} catch {
|
|
74
|
+
retire();
|
|
75
|
+
return stop();
|
|
76
|
+
} finally {
|
|
77
|
+
checking = false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const owner: InitialOwner = Object.freeze({
|
|
81
|
+
get basis() {
|
|
82
|
+
if (closed) stop();
|
|
83
|
+
return basis;
|
|
84
|
+
},
|
|
85
|
+
check,
|
|
86
|
+
sample: check,
|
|
87
|
+
retire,
|
|
88
|
+
subscribe(listener: () => void) {
|
|
89
|
+
if (typeof listener !== "function" || types.isProxy(listener)) {
|
|
90
|
+
retire();
|
|
91
|
+
stop();
|
|
92
|
+
}
|
|
93
|
+
if (closed) {
|
|
94
|
+
try {
|
|
95
|
+
listener();
|
|
96
|
+
} catch {
|
|
97
|
+
/* Already retired. */
|
|
98
|
+
}
|
|
99
|
+
return () => {};
|
|
100
|
+
}
|
|
101
|
+
const record = { fn: listener, active: true };
|
|
102
|
+
listeners.add(record);
|
|
103
|
+
return () => {
|
|
104
|
+
record.active = false;
|
|
105
|
+
listeners.delete(record);
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
owners.set(token, owner);
|
|
110
|
+
try {
|
|
111
|
+
check();
|
|
112
|
+
// Absolute original cutoff, never a new budget when a continuation resumes.
|
|
113
|
+
timer = setTimeout(
|
|
114
|
+
retire,
|
|
115
|
+
Math.max(0, basis.workEndWallMs - lineage.wall()),
|
|
116
|
+
);
|
|
117
|
+
timer.unref?.();
|
|
118
|
+
check();
|
|
119
|
+
return owner;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
retire();
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|