@wcstack/fetch 4.14.0 → 4.16.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/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +31 -44
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -68,7 +68,7 @@ function setConfig(partialConfig) {
|
|
|
68
68
|
frozenConfig = null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
var pkg = {"name":"@wcstack/fetch","version":"4.
|
|
71
|
+
var pkg = {"name":"@wcstack/fetch","version":"4.16.0"};
|
|
72
72
|
|
|
73
73
|
// ===========================================================================
|
|
74
74
|
// AUTO-GENERATED FILE - DO NOT EDIT.
|
|
@@ -91,14 +91,13 @@ class OperationLane {
|
|
|
91
91
|
_activeOperationIds = new Set();
|
|
92
92
|
// queue policy の FIFO。
|
|
93
93
|
_queue = [];
|
|
94
|
-
|
|
95
|
-
// opId → 終端状態 (absence = pending)。
|
|
96
|
-
_terminal = new Map();
|
|
97
|
-
// claimTerminal で確定した outcome (finalize が 'committing' を最終値へ移す)。
|
|
94
|
+
// opId → claimTerminal で確定した outcome。存在 = committing (finalize が確定させる)。
|
|
98
95
|
_claimedOutcome = new Map();
|
|
99
96
|
// opId → AbortController (identity は opId が保証。cross-op clobber は構造上起きない)。
|
|
100
97
|
_controllers = new Map();
|
|
101
|
-
// opId → attempt
|
|
98
|
+
// opId → attempt 数。存在 = live (begin 済みで finalize / dispose 前) で、in-flight はこの大きさ。
|
|
99
|
+
// 終わった operation は何も残さない — 終端済みの記録を持つと長く開いたページで際限なく増える
|
|
100
|
+
// (docs/formal-methods-study.md §4.1)。
|
|
102
101
|
_attempts = new Map();
|
|
103
102
|
_withSignal;
|
|
104
103
|
_trace;
|
|
@@ -112,7 +111,7 @@ class OperationLane {
|
|
|
112
111
|
return this._ownerGeneration;
|
|
113
112
|
}
|
|
114
113
|
get inFlightCount() {
|
|
115
|
-
return this.
|
|
114
|
+
return this._attempts.size;
|
|
116
115
|
}
|
|
117
116
|
get latestEpoch() {
|
|
118
117
|
return this._latestEpoch;
|
|
@@ -168,7 +167,6 @@ class OperationLane {
|
|
|
168
167
|
this._activeOperationIds.add(operationId);
|
|
169
168
|
break;
|
|
170
169
|
}
|
|
171
|
-
this._inFlightCount += 1;
|
|
172
170
|
this._attempts.set(operationId, 1);
|
|
173
171
|
const attempt = this._makeAttempt(operationId, 1);
|
|
174
172
|
if (this._trace !== undefined) {
|
|
@@ -178,15 +176,17 @@ class OperationLane {
|
|
|
178
176
|
}
|
|
179
177
|
/**
|
|
180
178
|
* retry: 同じ operationId に新しい attempt を作る。attempt number と resource signal
|
|
181
|
-
* だけを更新する (§5)
|
|
179
|
+
* だけを更新する (§5)。終端した・claim 済みの operation と、もう commit できない operation
|
|
180
|
+
* (supersede された latest / queue の先頭の後ろで待つもの) には作れない (null) — 結果を
|
|
181
|
+
* 捨てるしかない要求に新しい signal を渡さない (docs/formal-methods-study.md §4.1)。
|
|
182
182
|
*/
|
|
183
183
|
retry(ticket) {
|
|
184
184
|
if (ticket.ownerGeneration !== this._ownerGeneration)
|
|
185
185
|
return null;
|
|
186
|
-
if (this._terminal.has(ticket.operationId))
|
|
187
|
-
return null;
|
|
188
186
|
const previous = this._attempts.get(ticket.operationId);
|
|
189
|
-
if (previous === undefined)
|
|
187
|
+
if (previous === undefined || this._claimedOutcome.has(ticket.operationId))
|
|
188
|
+
return null;
|
|
189
|
+
if (!this._isEligible(ticket))
|
|
190
190
|
return null;
|
|
191
191
|
const attemptNo = previous + 1;
|
|
192
192
|
this._attempts.set(ticket.operationId, attemptNo);
|
|
@@ -205,9 +205,8 @@ class OperationLane {
|
|
|
205
205
|
canCommit(ticket) {
|
|
206
206
|
if (ticket.ownerGeneration !== this._ownerGeneration)
|
|
207
207
|
return false;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (status !== undefined && status !== "committing")
|
|
208
|
+
// live でなければ settle 済み。pending と committing (multi-setter commit 中) はどちらも settle 前。
|
|
209
|
+
if (!this._attempts.has(ticket.operationId))
|
|
211
210
|
return false;
|
|
212
211
|
return this._isEligible(ticket);
|
|
213
212
|
}
|
|
@@ -219,11 +218,11 @@ class OperationLane {
|
|
|
219
218
|
claimTerminal(ticket, outcome) {
|
|
220
219
|
if (ticket.ownerGeneration !== this._ownerGeneration)
|
|
221
220
|
return false;
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
// 終端済み (live でない) / 既に committing
|
|
222
|
+
if (!this._attempts.has(ticket.operationId) || this._claimedOutcome.has(ticket.operationId))
|
|
223
|
+
return false;
|
|
224
224
|
if (!this._isEligible(ticket))
|
|
225
225
|
return false;
|
|
226
|
-
this._terminal.set(ticket.operationId, "committing");
|
|
227
226
|
this._claimedOutcome.set(ticket.operationId, outcome);
|
|
228
227
|
return true;
|
|
229
228
|
}
|
|
@@ -237,25 +236,15 @@ class OperationLane {
|
|
|
237
236
|
*/
|
|
238
237
|
finalize(ticket) {
|
|
239
238
|
const operationId = ticket.operationId;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
// live でなければ確定済み (finalize 済み、または dispose が stale として確定した)。冪等に return —
|
|
240
|
+
// dispose 前の ticket が先へ進むと、新しい owner の in-flight を数え下げてしまう。
|
|
241
|
+
if (!this._attempts.has(operationId))
|
|
243
242
|
return;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if (status === "committing") {
|
|
247
|
-
outcome = this._claimedOutcome.get(operationId) ?? "stale";
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
// 一度も claim されなかった (supersede / dispose で eligibility を失った)。
|
|
251
|
-
outcome = "stale";
|
|
252
|
-
}
|
|
253
|
-
this._terminal.set(operationId, outcome);
|
|
243
|
+
// 一度も claim されなかった (supersede で eligibility を失った) なら stale。
|
|
244
|
+
const outcome = this._claimedOutcome.get(operationId) ?? "stale";
|
|
254
245
|
this._claimedOutcome.delete(operationId);
|
|
255
246
|
this._releaseController(operationId);
|
|
256
247
|
this._attempts.delete(operationId);
|
|
257
|
-
if (this._inFlightCount > 0)
|
|
258
|
-
this._inFlightCount -= 1;
|
|
259
248
|
this._advanceBookkeeping(operationId);
|
|
260
249
|
if (this._trace !== undefined) {
|
|
261
250
|
if (outcome === "stale") {
|
|
@@ -291,30 +280,28 @@ class OperationLane {
|
|
|
291
280
|
* dispose (§4.1 world generation)。owner generation を bump して全 ticket を無効化し、
|
|
292
281
|
* 生きている controller を全て abort する。dispose 後に settle した operation は
|
|
293
282
|
* owner gen 不一致で外部 commit しない。retention gate (§10.3) のため live な
|
|
294
|
-
* 全 operation を即時に stale
|
|
283
|
+
* 全 operation を即時に stale として確定し、controller / attempt を解放する。committing 中の
|
|
284
|
+
* operation も同じ — 残りの setter は owner gen で弾かれ、後の finalize は何もしない (終端の
|
|
285
|
+
* 報告は operation ごとに 1 回、docs/io-node-trace-conformance.md §6.3)。
|
|
295
286
|
*/
|
|
296
287
|
disposeOwner() {
|
|
297
288
|
this._ownerGeneration += 1;
|
|
298
289
|
for (const operationId of Array.from(this._controllers.keys())) {
|
|
299
290
|
this._abortController(operationId);
|
|
300
|
-
// finalize は dispose
|
|
301
|
-
//
|
|
291
|
+
// finalize は dispose 後に early-return するため controller を解放しない。
|
|
292
|
+
// retention gate (§10.3) を満たすためここで明示的に解放する。
|
|
302
293
|
this._releaseController(operationId);
|
|
303
294
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
this._terminal.set(operationId, "stale");
|
|
307
|
-
}
|
|
308
|
-
this._claimedOutcome.delete(operationId);
|
|
309
|
-
this._attempts.delete(operationId);
|
|
310
|
-
if (this._trace !== undefined) {
|
|
295
|
+
if (this._trace !== undefined) {
|
|
296
|
+
for (const operationId of this._attempts.keys()) {
|
|
311
297
|
this._trace({ type: "io:stale-dropped", operationId, laneKey: this.laneKey });
|
|
312
298
|
}
|
|
313
299
|
}
|
|
300
|
+
this._attempts.clear();
|
|
301
|
+
this._claimedOutcome.clear();
|
|
314
302
|
this._activeOperationId = undefined;
|
|
315
303
|
this._activeOperationIds.clear();
|
|
316
304
|
this._queue.length = 0;
|
|
317
|
-
this._inFlightCount = 0;
|
|
318
305
|
}
|
|
319
306
|
// --- internal ---
|
|
320
307
|
_makeAttempt(operationId, attemptNo) {
|