Skip to content

perf(web): load page code on first use, not at boot - #1946

Open
Makisuo wants to merge 5 commits into
mainfrom
perf/lazy-page-modules
Open

Makisuo wants to merge 5 commits into
mainfrom
perf/lazy-page-modules

perf(web): import the page code statically from boot.ts

8e82ad5
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Oct 30, 2026 in 1m 6s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge
The reviewed delta is a dynamic-to-static import swap in the web boot entry; the route table it drives has no ambiguous match and page/code.test.ts pins it.
no findings · tests covered · risk medium · 1/1 new units observable

Since the last review the only change is boot.ts importing page/code statically (plus a comment), so the route's chunk starts without waiting for the app graph. Safe to merge. The open @maple/mcp/errors/McpQueryError issues are in apps/ai's MCP tool registry, not the page registry their stacks name, and this PR does not address them.

  • boot.ts statically imports startRoutePageCode from page/code instead of a dynamic import()

Production impact

Open errors in the changed files
Issue Service Occurrences File
@maple/mcp/errors/McpQueryError maple-chat 831 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-ai 226 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-chat 222 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-chat 75 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-ai 63 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-ai 36 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-chat 33 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-chat 24 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-ai 24 apps/web/src/page/registry.ts
@maple/mcp/errors/McpQueryError maple-chat 18 apps/web/src/page/registry.ts

After this merges, Maple checks whether they stop.

Production traffic of the changed files (last 7 days)
File Calls/day Busiest operations
apps/web/src/page/code.ts 24k POST /mcp 12k/day, 0.0% err
POST /mcp 12k/day, 0.0% err
GET /mcp 457/day, 0.0% err
apps/web/src/page/settings/mcp-page/implementation.ts 24k POST /mcp 12k/day, 0.0% err
POST /mcp 12k/day, 0.0% err
GET /mcp 457/day, 0.0% err
apps/web/src/page/settings/mcp-page/index.ts 24k POST /mcp 12k/day, 0.0% err
POST /mcp 12k/day, 0.0% err
GET /mcp 457/day, 0.0% err
apps/web/src/platform/telemetry.ts 144 LoadClerk 126/day, 0.0% err
LoadPageCode 18/day, 0.0% err
apps/web/src/page/traces/detail/implementation.ts 22 FetchSpanHierarchy 22/day, 0.0% err
apps/web/src/page/traces/detail/index.ts 22 FetchSpanHierarchy 22/day, 0.0% err
apps/web/src/command.ts 18 LoadPageCode 18/day, 0.0% err
What was checked
  • pageCodeIdOf precedence: no two table entries tie on a matching path; /alerts/create, /dashboards/:/widgets/:, /infra/aws/:/* resolve as intended (ran the matcher over the table)
  • shared in page/code.ts keeps one import per page and drops a rejected promise so a reload can retry; boot.ts handles its rejection
  • page/code.ts still has no static imports, so the boot graph gains only the route table, not page code
Observability coverage: 1 of 1 changes observable
Change Kind Observable Evidence
boot.ts early start of the route's page chunk (startRoutePageCode) outbound chunk load yes The shared import it starts is measured by the LoadPageCode span in apps/web/src/command.ts:106-116 (maple.page.id, maple.page.code_for_preload)

8e82ad5 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.