Skip to content

feat(ud): Register routes with UD using addEntry#1723

Merged
Tobbe merged 6 commits into
mainfrom
tobbe-ud-phase-6
May 6, 2026
Merged

feat(ud): Register routes with UD using addEntry#1723
Tobbe merged 6 commits into
mainfrom
tobbe-ud-phase-6

Conversation

@Tobbe

@Tobbe Tobbe commented May 6, 2026

Copy link
Copy Markdown
Member

This PR adds per-route addEntry() UD registrations. Each discovered API function (GraphQL, auth, health, regular functions) gets its own virtual module and UD store entry

@netlify

netlify Bot commented May 6, 2026

Copy link
Copy Markdown

Deploy Preview for cedarjs ready!

Name Link
🔨 Latest commit 4e6e79b
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/69faf920245f8b00082409a1
😎 Deploy Preview https://deploy-preview-1723--cedarjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added this to the next-release milestone May 6, 2026
@greptile-apps

greptile-apps Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the single aggregate buildCedarDispatcher with per-route addEntry() registrations, giving UD adapters the metadata to split individual Cedar API functions into separate deployment units. udDispatcher.ts is deleted; its logic is split across three new ud-handlers/ modules and virtual module generation in cedarUniversalDeployPlugin.

  • cedarUniversalDeployPlugin now calls discoverCedarRoutes() to build a manifest and registers one addEntry() call per discovered function plus a final catch-all entry; the Vite load hook generates typed virtual modules for each route.
  • graphql.ts correctly fixes the previous concurrent-init race by storing a yogaInitPromise; function.ts changes the expected export name from handle to handleRequest, silently breaking existing migrated functions.

Confidence Score: 4/5

The core routing and UD registration logic is sound, but the rename from handle to handleRequest in function.ts will silently break existing functions that followed the old migration guide.

The deleted udDispatcher.ts explicitly documented export async function handle(request, ctx) as the required migration target. The new function.ts looks for handleRequest instead with no fallback, so any function that already migrated will throw at runtime. Everything else looks correct.

packages/vite/src/ud-handlers/function.ts — the handler export name lookup needs attention before this lands.

Important Files Changed

Filename Overview
packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts Core plugin rewrite: registers per-route UD entries via addEntry and generates virtual modules; handler-name rename (handle → handleRequest) is a silent breaking change; route discovery called eagerly at instantiation
packages/vite/src/ud-handlers/function.ts New function handler; looks for handleRequest export instead of the old handle convention — silent runtime breakage for existing migrated functions
packages/vite/src/ud-handlers/graphql.ts New GraphQL handler; correctly memoizes Yoga initialization with a promise-based lock, fixing the concurrent-init race from the previous review
packages/vite/src/ud-handlers/catch-all.ts New catch-all dispatcher with rou3 routing, 500-error guard, and apiRootPath stripping; still missing AsyncLocalStorage per-request context initialization
packages/api/src/runtime.ts Adds id field to CedarRouteRecord interface for UD entry mapping; non-breaking additive change
packages/api-server/src/plugins/lambdaLoader.ts Adds id field to route manifest entries; changes non-graphql methods from ['GET', 'POST'] to [] (matches-all semantics for UD store)
packages/api-server/src/udDispatcher.ts File deleted; functionality split into new ud-handlers modules and vite plugin virtual module generation
packages/vite/src/buildUDApiServer.ts Comment/doc update only to reflect new per-route registration approach

Reviews (5): Last reviewed commit: "ud-handlers" | Re-trigger Greptile

Comment thread packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts Outdated
Comment thread packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts Outdated
@nx-cloud

nx-cloud Bot commented May 6, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 4e6e79b

Command Status Duration Result
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 2s View ↗
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 3m 5s View ↗
nx run-many -t build ✅ Succeeded 5s View ↗
nx run-many -t test:types ✅ Succeeded 7s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-06 08:37:39 UTC

Comment thread packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts Outdated
Comment thread packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts Outdated
Comment thread packages/vite/src/ud-handlers/function.ts
@Tobbe Tobbe merged commit da5a312 into main May 6, 2026
46 checks passed
@Tobbe Tobbe deleted the tobbe-ud-phase-6 branch May 6, 2026 08:50
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

The changes in this PR are now available on npm.

Try them out by running yarn cedar upgrade -t 5.0.0-canary.13897

Or try it in a new app with yarn dlx create-cedar-app@5.0.0-canary.13897

@Tobbe Tobbe modified the milestones: next-release, v4.2.0 May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant