Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/runtime/src/internal/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,8 @@ async function legacyRenderBrick(
}
}

// When result is null, it means the incremental rendering is tried but routes missed.
// In this case, we should continue to re-render the parent routes.
return incrementalOutput.route ? true : null;
// Even if all sub-routes missed, treat the incremental rendering as performed.
return true;
}
);
}
Expand Down
17 changes: 12 additions & 5 deletions packages/runtime/src/internal/RendererContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type MemoizedLifeCycle<T> = {
type LocationChangeCallback = (
location: Location<NextHistoryState>,
prevLocation: Location<NextHistoryState>
) => Promise<boolean | null>;
) => Promise<boolean>;

interface IncrementalRenderState {
parentRoutes: RouteConf[];
Expand Down Expand Up @@ -71,7 +71,12 @@ export interface RendererContextOptions {
export interface RouteHelper {
bailout: (output: RenderOutput) => true | undefined;
mergeMenus: (menuRequests: Promise<StaticMenuConf>[]) => Promise<void>;
/** Will always resolve */
/**
* Will always resolve when the routing is not the current bootstrap.
* Otherwise, will throw an error when not bailout.
*
* @returns undefined when bailout, or failed output otherwise
*/
catch: (
error: unknown,
returnNode: RenderReturnNode,
Expand Down Expand Up @@ -226,7 +231,10 @@ export class RendererContext {
}

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