@solidjs/router 2.0.0-next.32 → 2.0.0-next.33

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.
@@ -1,4 +1,4 @@
1
- import { createSignal, getObserver, getOwner, isHydratable, onCleanup, untrack } from "solid-js";
1
+ import { createSignal, getObserver, getOwner, isHydratable, isHydrating, onCleanup, untrack } from "solid-js";
2
2
  // Everything server-function-shaped comes off the CORE entry: detection
3
3
  // (isServerFunction/getServerFunctionMetadata, registered-symbol reads) and
4
4
  // the late-bound RPC seam (getServerFunctionRPC). The transport itself —
@@ -37,6 +37,13 @@ const forwardedCookies = /* #__PURE__ */ new WeakMap();
37
37
  // hold values the server computed while rendering THIS page, so their age is
38
38
  // anchored here — not at whenever a late query() call happens to consume one.
39
39
  const bootTime = Date.now();
40
+ // Captured at module load: a hydrating client runs a serialized node's
41
+ // compute once as a dependency trace with the global `Promise` swapped for a
42
+ // never-settling mock, and a query() read inside that trace still consumes
43
+ // and caches its flight entry. Wrapped with the global there, a settled
44
+ // entry would cache a promise that never resolves, hanging every navigation
45
+ // that reuses it.
46
+ const NativePromise = Promise;
40
47
  // Every hydratable read ships its entry: the writer keeps the first write
41
48
  // per key, so a read skipped in a NoHydration zone never hides the entry
42
49
  // from an island that reads the same key later.
@@ -165,11 +172,18 @@ export function query(fn, name) {
165
172
  tracking = true;
166
173
  onCleanup(() => cached[4].count--);
167
174
  }
175
+ // A read with no navigation in flight while hydrating is claiming server
176
+ // DOM, so it takes the cached entry at any age — the rule adoption below
177
+ // applies to flight entries. It can come from a boundary resuming long
178
+ // after boot, once the entry was adopted and its first reader disposed;
179
+ // refetching there would run inside Solid's hydration trace, where fetch
180
+ // and Promise never settle, and cache that.
168
181
  if (cached &&
169
182
  cached[0] &&
170
183
  (isServer ||
171
184
  intent === "native" ||
172
185
  cached[4].count ||
186
+ (!intent && isHydrating()) ||
173
187
  Date.now() - cached[0] < PRELOAD_TIMEOUT)) {
174
188
  if (tracking) {
175
189
  cached[4].count++;
@@ -210,8 +224,8 @@ export function query(fn, name) {
210
224
  entry.status === "pending"
211
225
  ? entry.promise
212
226
  : entry.status === "resolved"
213
- ? Promise.resolve(entry.value)
214
- : Promise.reject(entry.error);
227
+ ? NativePromise.resolve(entry.value)
228
+ : NativePromise.reject(entry.error);
215
229
  }
216
230
  // A payload too old for this intent stays in the registry: it is
217
231
  // inert while the refetched entry below lives, but a later claim
@@ -220,11 +234,10 @@ export function query(fn, name) {
220
234
  if (!adopted)
221
235
  res = fn(...args);
222
236
  // Adopted entries are stamped at boot — when their data was actually
223
- // fetched — not at consumption. The hydration render burst still dedups
224
- // through the normal window/count reuse above (it happens within
225
- // milliseconds of boot), while a navigation that comes along later sees
226
- // the payload's true age and refetches past PRELOAD_TIMEOUT, exactly as
227
- // it would for a preload performed when the server fetched the data.
237
+ // fetched — not at consumption. Later hydration reads still reuse them
238
+ // through the claim rule above, while a navigation that comes along later
239
+ // sees the payload's true age and refetches past PRELOAD_TIMEOUT, exactly
240
+ // as it would for a preload performed when the server fetched the data.
228
241
  const stamp = adopted ? bootTime : now;
229
242
  if (cached) {
230
243
  isServer && forwardedCookies.delete(cached);
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwner, runWithOwner, createMemo, createRenderEffect, onCleanup, untrack, createContext, createSignal, useContext, NotReadyError, DEV, isPending, latest, createComponent, createRoot, Show, createEffect, OBSERVE, onSettled, getObserver, isHydratable, $TRACK, action as action$1 } from 'solid-js';
1
+ import { getOwner, runWithOwner, createMemo, createRenderEffect, onCleanup, untrack, createContext, createSignal, useContext, NotReadyError, DEV, isPending, latest, createComponent, createRoot, Show, createEffect, OBSERVE, onSettled, getObserver, isHydrating, isHydratable, $TRACK, action as action$1 } from 'solid-js';
2
2
  import { registerElementClaim, delegateEvents, isServer, getRequestEvent, hasFlashCookie, clearFlashCookie, createComponent as createComponent$1, memo, dynamic, isServerFunction, getServerFunctionMetadata, getServerFunctionRPC, takeHydrationValue, isResponseEnvelope, REVALIDATE_HEADER, getHydrationWriter } from '@solidjs/web';
3
3
  import { REDIRECT_HEADER, decodeRedirectHeaderValue, subscribeFlightData, decodeResponsePayload, parseServerFunctionActionUrl, createServerReference } from '@solidjs/web/server-functions';
4
4
 
@@ -2663,6 +2663,13 @@ const forwardedCookies = /* #__PURE__ */new WeakMap();
2663
2663
  // hold values the server computed while rendering THIS page, so their age is
2664
2664
  // anchored here — not at whenever a late query() call happens to consume one.
2665
2665
  const bootTime = Date.now();
2666
+ // Captured at module load: a hydrating client runs a serialized node's
2667
+ // compute once as a dependency trace with the global `Promise` swapped for a
2668
+ // never-settling mock, and a query() read inside that trace still consumes
2669
+ // and caches its flight entry. Wrapped with the global there, a settled
2670
+ // entry would cache a promise that never resolves, hanging every navigation
2671
+ // that reuses it.
2672
+ const NativePromise = Promise;
2666
2673
 
2667
2674
  // Every hydratable read ships its entry: the writer keeps the first write
2668
2675
  // per key, so a read skipped in a NoHydration zone never hides the entry
@@ -2787,7 +2794,14 @@ function query(fn, name) {
2787
2794
  tracking = true;
2788
2795
  onCleanup(() => cached[4].count--);
2789
2796
  }
2790
- if (cached && cached[0] && (isServer || intent === "native" || cached[4].count || Date.now() - cached[0] < PRELOAD_TIMEOUT$1)) {
2797
+
2798
+ // A read with no navigation in flight while hydrating is claiming server
2799
+ // DOM, so it takes the cached entry at any age — the rule adoption below
2800
+ // applies to flight entries. It can come from a boundary resuming long
2801
+ // after boot, once the entry was adopted and its first reader disposed;
2802
+ // refetching there would run inside Solid's hydration trace, where fetch
2803
+ // and Promise never settle, and cache that.
2804
+ if (cached && cached[0] && (isServer || intent === "native" || cached[4].count || !intent && isHydrating() || Date.now() - cached[0] < PRELOAD_TIMEOUT$1)) {
2791
2805
  if (tracking) {
2792
2806
  cached[4].count++;
2793
2807
  cached[4][0](); // track
@@ -2822,7 +2836,7 @@ function query(fn, name) {
2822
2836
  const entry = takeHydrationValue(key); // hydrating
2823
2837
  if (entry) {
2824
2838
  adopted = true;
2825
- res = entry.status === "pending" ? entry.promise : entry.status === "resolved" ? Promise.resolve(entry.value) : Promise.reject(entry.error);
2839
+ res = entry.status === "pending" ? entry.promise : entry.status === "resolved" ? NativePromise.resolve(entry.value) : NativePromise.reject(entry.error);
2826
2840
  }
2827
2841
  // A payload too old for this intent stays in the registry: it is
2828
2842
  // inert while the refetched entry below lives, but a later claim
@@ -2831,11 +2845,10 @@ function query(fn, name) {
2831
2845
  if (!adopted) res = fn(...args);
2832
2846
 
2833
2847
  // Adopted entries are stamped at boot — when their data was actually
2834
- // fetched — not at consumption. The hydration render burst still dedups
2835
- // through the normal window/count reuse above (it happens within
2836
- // milliseconds of boot), while a navigation that comes along later sees
2837
- // the payload's true age and refetches past PRELOAD_TIMEOUT, exactly as
2838
- // it would for a preload performed when the server fetched the data.
2848
+ // fetched — not at consumption. Later hydration reads still reuse them
2849
+ // through the claim rule above, while a navigation that comes along later
2850
+ // sees the payload's true age and refetches past PRELOAD_TIMEOUT, exactly
2851
+ // as it would for a preload performed when the server fetched the data.
2839
2852
  const stamp = adopted ? bootTime : now;
2840
2853
  if (cached) {
2841
2854
  isServer && forwardedCookies.delete(cached);
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "Ryan Turnquist"
7
7
  ],
8
8
  "license": "MIT",
9
- "version": "2.0.0-next.32",
9
+ "version": "2.0.0-next.33",
10
10
  "homepage": "https://github.com/solidjs/solid-router#readme",
11
11
  "repository": {
12
12
  "type": "git",