@uniweb/core 0.8.2 → 0.8.3
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/package.json +1 -1
- package/src/fetcher-dispatcher.js +15 -1
package/package.json
CHANGED
|
@@ -227,8 +227,22 @@ export default class FetcherDispatcher {
|
|
|
227
227
|
const cached = this._dataStore.get(key)
|
|
228
228
|
if (cached) return { data: cached.data, meta: cached.meta }
|
|
229
229
|
|
|
230
|
+
// An in-flight entry whose master has ALREADY aborted is a corpse: its
|
|
231
|
+
// underlying request is cancelled and its promise will settle to
|
|
232
|
+
// `{ data: [], error: 'aborted' }`. Attaching to it would hand this caller
|
|
233
|
+
// a cancelled result it never asked to cancel — `_attachSignal` has no way
|
|
234
|
+
// to re-arm a fired master. Treat it as a miss and start a fresh fetch.
|
|
235
|
+
//
|
|
236
|
+
// This is the sequential counterpart to the refcounting below. Refcounting
|
|
237
|
+
// covers CONCURRENT waiters (B attaches before A aborts, so the master
|
|
238
|
+
// stays live). It cannot cover SEQUENTIAL ones (A aborts, then B arrives),
|
|
239
|
+
// which is exactly React StrictMode's dev double-mount: the cleanup and the
|
|
240
|
+
// re-run happen in one synchronous commit, so B always lands in the window
|
|
241
|
+
// after the abort and before `_runFetcher`'s continuation clears the entry.
|
|
242
|
+
// Without this check the second mount inherits the first mount's abort and
|
|
243
|
+
// the block renders empty data — see tests/fetcher-dispatcher.test.js.
|
|
230
244
|
const existing = this._dataStore.inflight.get(key)
|
|
231
|
-
if (existing) {
|
|
245
|
+
if (existing && !existing.master?.signal.aborted) {
|
|
232
246
|
this._attachSignal(existing, ctx.signal)
|
|
233
247
|
return existing.promise
|
|
234
248
|
}
|