@rangojs/router 0.0.0-experimental.preview.1774282886 → 0.0.0-experimental.preview.1774283292
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/vite/index.js
CHANGED
|
@@ -1745,7 +1745,7 @@ import { resolve } from "node:path";
|
|
|
1745
1745
|
// package.json
|
|
1746
1746
|
var package_default = {
|
|
1747
1747
|
name: "@rangojs/router",
|
|
1748
|
-
version: "0.0.0-experimental.preview.
|
|
1748
|
+
version: "0.0.0-experimental.preview.1774283292",
|
|
1749
1749
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1750
1750
|
keywords: [
|
|
1751
1751
|
"react",
|
package/package.json
CHANGED
|
@@ -114,32 +114,8 @@ export function createNavigationClient(
|
|
|
114
114
|
resolveStreamComplete = resolve;
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
// Dev-only: debug channel is created lazily only for fresh fetches.
|
|
118
|
-
// Cached/inflight responses don't have a server-side channel, so passing
|
|
119
|
-
// debugChannel to createFromFetch would hang waiting for data that never comes.
|
|
120
|
-
let debugChannel: ClientDebugChannel | null = null;
|
|
121
|
-
|
|
122
|
-
// Clean up debug channel if navigation is aborted (new nav starts)
|
|
123
|
-
signal?.addEventListener(
|
|
124
|
-
"abort",
|
|
125
|
-
() => {
|
|
126
|
-
debugChannel?.destroy();
|
|
127
|
-
debugChannel = null;
|
|
128
|
-
},
|
|
129
|
-
{ once: true },
|
|
130
|
-
);
|
|
131
|
-
|
|
132
117
|
/** Start a fresh navigation fetch (no cache / inflight hit). */
|
|
133
|
-
const doFreshFetch = (
|
|
134
|
-
// Dev-only: create debug channel for React Performance Tracks
|
|
135
|
-
const debugId = enableDebugChannel && (import.meta as any).hot
|
|
136
|
-
? crypto.randomUUID()
|
|
137
|
-
: undefined;
|
|
138
|
-
debugChannel = null;
|
|
139
|
-
if (debugId) {
|
|
140
|
-
debugChannel = createClientDebugChannel(debugId);
|
|
141
|
-
console.log("[perf-tracks] client: fresh fetch, debugId =", debugId);
|
|
142
|
-
}
|
|
118
|
+
const doFreshFetch = (): Promise<Response> => {
|
|
143
119
|
|
|
144
120
|
if (tx) {
|
|
145
121
|
browserDebugLog(tx, "fetching", {
|
|
@@ -156,7 +132,6 @@ export function createNavigationClient(
|
|
|
156
132
|
"X-RSC-Router-Intercept-Source": interceptSourceUrl,
|
|
157
133
|
}),
|
|
158
134
|
...(hmr && { "X-RSC-HMR": "1" }),
|
|
159
|
-
...(debugId && { [DEBUG_ID_HEADER]: debugId }),
|
|
160
135
|
},
|
|
161
136
|
signal,
|
|
162
137
|
}).then((response) => {
|
|
@@ -233,7 +208,7 @@ export function createNavigationClient(
|
|
|
233
208
|
if (tx) {
|
|
234
209
|
browserDebugLog(tx, "inflight prefetch unavailable, refetching");
|
|
235
210
|
}
|
|
236
|
-
return doFreshFetch(
|
|
211
|
+
return doFreshFetch();
|
|
237
212
|
}
|
|
238
213
|
|
|
239
214
|
return teeWithCompletion(
|
|
@@ -248,47 +223,16 @@ export function createNavigationClient(
|
|
|
248
223
|
);
|
|
249
224
|
});
|
|
250
225
|
} else {
|
|
251
|
-
responsePromise = doFreshFetch(
|
|
226
|
+
responsePromise = doFreshFetch();
|
|
252
227
|
}
|
|
253
228
|
|
|
254
229
|
try {
|
|
255
|
-
//
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (activeDebugChannel) {
|
|
262
|
-
try {
|
|
263
|
-
payload = await deps.createFromFetch<RscPayload>(
|
|
264
|
-
responsePromise,
|
|
265
|
-
{ debugChannel: activeDebugChannel, findSourceMapURL },
|
|
266
|
-
);
|
|
267
|
-
// Success — let the debug channel close naturally via
|
|
268
|
-
// the server's "done" signal, don't destroy() here.
|
|
269
|
-
} catch (e) {
|
|
270
|
-
console.warn(
|
|
271
|
-
"[perf-tracks] createFromFetch with debug channel failed for",
|
|
272
|
-
fetchUrl.pathname,
|
|
273
|
-
e,
|
|
274
|
-
);
|
|
275
|
-
// Destroy the debug channel on error to clean up HMR listeners
|
|
276
|
-
(activeDebugChannel as any).destroy();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// If debug channel produced invalid payload, retry without it
|
|
280
|
-
if (!payload?.metadata) {
|
|
281
|
-
console.warn(
|
|
282
|
-
"[perf-tracks] invalid payload with debug channel, retrying without for",
|
|
283
|
-
fetchUrl.pathname,
|
|
284
|
-
);
|
|
285
|
-
(activeDebugChannel as any).destroy();
|
|
286
|
-
const retryResponse = doFreshFetch(false);
|
|
287
|
-
payload = await deps.createFromFetch<RscPayload>(retryResponse);
|
|
288
|
-
}
|
|
289
|
-
} else {
|
|
290
|
-
payload = await deps.createFromFetch<RscPayload>(responsePromise);
|
|
291
|
-
}
|
|
230
|
+
// Debug channel is disabled for SPA navigations — React's internal
|
|
231
|
+
// close protocol for the debug readable conflicts with our teardown,
|
|
232
|
+
// causing "Connection closed." errors that crash the error boundary.
|
|
233
|
+
// SSR/hydration debug channel works fine (controlled lifecycle).
|
|
234
|
+
// TODO: investigate proper close handshake for SPA debug streams.
|
|
235
|
+
const payload = await deps.createFromFetch<RscPayload>(responsePromise);
|
|
292
236
|
|
|
293
237
|
if (tx) {
|
|
294
238
|
browserDebugLog(tx, "response received", {
|
|
@@ -299,34 +243,6 @@ export function createNavigationClient(
|
|
|
299
243
|
}
|
|
300
244
|
return { payload, streamComplete };
|
|
301
245
|
} catch (error) {
|
|
302
|
-
if (
|
|
303
|
-
debugChannel &&
|
|
304
|
-
!cachedResponse &&
|
|
305
|
-
!inflightResponsePromise &&
|
|
306
|
-
isDebugChannelClosureError(error)
|
|
307
|
-
) {
|
|
308
|
-
console.warn(
|
|
309
|
-
"[perf-tracks] navigation debug stream closed early, retrying without debug channel for",
|
|
310
|
-
fetchUrl.pathname,
|
|
311
|
-
);
|
|
312
|
-
if (tx) {
|
|
313
|
-
browserDebugLog(tx, "debug stream closed early, retrying", {
|
|
314
|
-
path: `${fetchUrl.pathname}${fetchUrl.search}`,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
const retryResponsePromise = doFreshFetch(false);
|
|
318
|
-
const payload = await deps.createFromFetch<RscPayload>(
|
|
319
|
-
retryResponsePromise,
|
|
320
|
-
);
|
|
321
|
-
if (tx) {
|
|
322
|
-
browserDebugLog(tx, "response received after debug retry", {
|
|
323
|
-
isPartial: payload.metadata?.isPartial,
|
|
324
|
-
matchedCount: payload.metadata?.matched?.length ?? 0,
|
|
325
|
-
diffCount: payload.metadata?.diff?.length ?? 0,
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
return { payload, streamComplete };
|
|
329
|
-
}
|
|
330
246
|
// Convert network-level errors to NetworkError for proper handling
|
|
331
247
|
if (isNetworkError(error)) {
|
|
332
248
|
throw new NetworkError(
|