Repository navigation
perf: index static app-core routes for O(1) dispatch - #951
Merged
Merged
Conversation
Look up exact paths in a Map instead of scanning the compiled table, and keep falling through to parameter and catch-all routes after a method miss. Co-authored-by: Jon Wheeler <[email protected]>
jonkwheeler
marked this pull request as ready for review
September 4, 2026 14:14
Typecheck treats compiled.pattern as string | RegExp. Guard the dynamic scan so exec is only called on a RegExp. Co-authored-by: Jon Wheeler <[email protected]>
postcss 8.5.28 makes DeclarationProps extend NodeProps, which tsrx-tsc cannot resolve. The packed-consumer smoke now overrides postcss to 8.5.26 so that gate is not broken by the types publish. Co-authored-by: Jon Wheeler <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Postcss pin ignored under pnpm 11
- Moved the postcss 8.5.26 pin from ignored package.json pnpm.overrides into pnpm-workspace.yaml via renderPackedExampleWorkspace so pnpm 11 applies it.
Or push these changes by commenting:
@cursor push e3052f19fb
Preview (e3052f19fb)
diff --git a/scripts/check-package-packs.mjs b/scripts/check-package-packs.mjs
--- a/scripts/check-package-packs.mjs
+++ b/scripts/check-package-packs.mjs
@@ -478,20 +478,20 @@
typescript: typescriptVersion,
vite: viteVersion,
},
- // postcss 8.5.28 makes DeclarationProps extend NodeProps, but
- // tsrx-tsc cannot resolve that named export from node.d.ts
- // (TS2304). Pin the last types that typecheck here.
- pnpm: {
- overrides: {
- postcss: '8.5.26',
- },
- },
},
null,
2,
) + '\n',
);
+ // postcss 8.5.28 makes DeclarationProps extend NodeProps, but
+ // tsrx-tsc cannot resolve that named export from node.d.ts
+ // (TS2304). Pin the last types that typecheck here. pnpm 11 reads
+ // overrides from pnpm-workspace.yaml, not package.json pnpm.overrides.
writeFileSync(
+ path.join(consumerDirectory, 'pnpm-workspace.yaml'),
+ renderPackedExampleWorkspace({ postcss: '8.5.26' }),
+ );
+ writeFileSync(
path.join(sourceDirectory, 'App.tsrx'),
`import { ApolloClient, InMemoryCache } from '@octanejs/apollo-client';
import { ApolloProvider, useApolloClient } from '@octanejs/apollo-client/react';You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit c97e755. Configure here.
pnpm 11 ignores package.json pnpm.overrides in this isolated consumer. Write the same override in pnpm-workspace.yaml as the other packed consumers, and assert the resolved postcss version after install. Co-authored-by: Jon Wheeler <[email protected]>
This was referenced Sep 4, 2026
|
READY FOR REVIEW |
cursor Bot
pushed a commit
that referenced
this pull request
Sep 6, 2026
Compose the #951 static path Map with last-static-segment dynamic indexing and keep both sides' router tests. Co-authored-by: Jon Wheeler <[email protected]>
14 of 21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
@octanejs/app-coreroutes by path socreateRouter().match()is O(1) instead of a linear scan of the compiled table./apidoes not hide/*rest.Why
router-dispatchmeasures a 1,000-route table and still walked every candidate for a last-row static hit or a lowercase method miss. Exact-string compare already beat RegExp, but the scan itself dominated. A path map removes that work without changing match semantics.Changes
packages/app-core/src/server/router.js: split compiled routes into a staticMapand a dynamic list; consult the map first. Dynamic candidates narrowpatterntoRegExpbeforeexec.packages/app-core/tests/router.test.ts: pin method-miss → catch-all fall-through, shared-path method selection, and same-path render fallback.@octanejs/app-core(patch).scripts/check-package-packs.mjs: pin packed-consumer PostCSS to 8.5.26 viapnpm-workspace.yaml(pnpm 11;package.jsonpnpm.overridesdoes not apply here). postcss 8.5.28'sDeclarationProps extends NodePropsfailstsrx-tsc(TS2304) on every current-head pack job, including unrelated PRs. Install asserts the resolved version.Benchmarks
Environment: Node v22.22.2, Linux 6.12.94+ x86_64, 4 CPUs. Command:
node benchmarks/router-dispatch/run.mjs 20. Scores are ms/million candidates (lower is better). A/B/A/B on the same machine:Existing ratio guards (
static/wrong-methodvsdynamic,maxRatio: 0.2) remain valid and become much looser.Validation
pnpm format:check(not run; scoped Prettier on the changed files)pnpm typecheckvia CI on9f099eca1(required typecheck job green)pnpm testvia CI on9f099eca1(Node 24 shards, React-parity, lint, examples, Lynx/Three)packages/app-core/tests/router.test.ts(4 tests). The catch-all fall-through case was confirmed red when the static miss returnednullbefore the dynamic scan, then green after restore.node benchmarks/router-dispatch/run.mjs 20A/B/A/B as above9f099eca1workspace-yaml PostCSS pin;validate publishable packagesandCI provenancegreenRisk / follow-ups
paramsobject; public match identity and decoded params are unchanged.NodePropsundertsrx-tsc.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.