Skip to content

Commit 5af96e2

Browse files
committed
fix(): treat the incremental render as performed even if all sub-routes missed
1 parent 62b92d3 commit 5af96e2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

packages/runtime/src/internal/Renderer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,9 +961,8 @@ async function legacyRenderBrick(
961961
}
962962
}
963963

964-
// When result is null, it means the incremental rendering is tried but routes missed.
965-
// In this case, we should continue to re-render the parent routes.
966-
return incrementalOutput.route ? true : null;
964+
// Even if all sub-routes missed, treat the incremental rendering as performed.
965+
return true;
967966
}
968967
);
969968
}

packages/runtime/src/internal/RendererContext.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type MemoizedLifeCycle<T> = {
3737
type LocationChangeCallback = (
3838
location: Location<NextHistoryState>,
3939
prevLocation: Location<NextHistoryState>
40-
) => Promise<boolean | null>;
40+
) => Promise<boolean>;
4141

4242
interface IncrementalRenderState {
4343
parentRoutes: RouteConf[];
@@ -71,7 +71,12 @@ export interface RendererContextOptions {
7171
export interface RouteHelper {
7272
bailout: (output: RenderOutput) => true | undefined;
7373
mergeMenus: (menuRequests: Promise<StaticMenuConf>[]) => Promise<void>;
74-
/** Will always resolve */
74+
/**
75+
* Will always resolve when the routing is not the current bootstrap.
76+
* Otherwise, will throw an error when not bailout.
77+
*
78+
* @returns undefined when bailout, or failed output otherwise
79+
*/
7580
catch: (
7681
error: unknown,
7782
returnNode: RenderReturnNode,
@@ -226,7 +231,10 @@ export class RendererContext {
226231
}
227232

228233
/**
229-
* Will always resolve
234+
* Will always resolve when the routing is not the current bootstrap.
235+
* Otherwise, will throw an error when not bailout.
236+
*
237+
* @returns undefined when bailout, or failed output otherwise
230238
*/
231239
reCatch(error: unknown, returnNode: RenderReturnNode) {
232240
return this.#routeHelper!.catch(error, returnNode, false, true);
@@ -255,8 +263,7 @@ export class RendererContext {
255263
continue;
256264
}
257265
const result = await callback(location, prevLocation);
258-
// When result is null, it means the incremental rendering is tried but routes missed.
259-
// In this case, we should continue to re-render the parent routes.
266+
// When result is true, it means the incremental rendering is performed.
260267
if (result) {
261268
shouldIgnoreRoutes.push(...parentRoutes.slice(0, -1));
262269
}

0 commit comments

Comments
 (0)