Skip to content

feat(ud): Debugger support#2015

Merged
Tobbe merged 6 commits into
mainfrom
tobbe-feat-ud-debug
Jun 29, 2026
Merged

feat(ud): Debugger support#2015
Tobbe merged 6 commits into
mainfrom
tobbe-feat-ud-debug

Conversation

@Tobbe

@Tobbe Tobbe commented Jun 28, 2026

Copy link
Copy Markdown
Member

Pass through --debug-port to cedar-unified-dev's startUnifiedDevServer() and attach the node inspector to vite's node process. Also adds --debug-brk which probably is what you want to use most of the time when debugging in an IDE. Launch with that flag from your debug configurations.

For attaching to an already-running server, you'll have to trigger HMR in the file you want to debug for Vite to invalidate its cache and load the module again, which lets the debugger properly discover the breakpoint and break on it

@netlify

netlify Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploy Preview for cedarjs ready!

Name Link
🔨 Latest commit 37e66da
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6a4253d82231950008222ea2
😎 Deploy Preview https://deploy-preview-2015--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 Jun 28, 2026
@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds debugger support for unified dev mode. The main changes are:

  • --debug-port parsing and inspector startup in cedar-unified-dev.
  • A --debug-brk flag that waits for a debugger before continuing startup.
  • Unit and integration coverage for debugger attach and pause/resume flows.
  • Documentation for the UD inspector behavior and Vite SSR breakpoint limits.
  • A new ws dev dependency for CDP WebSocket tests.

Confidence Score: 4/5

This is close, but the debug-port propagation should be fixed before merging.

  • Direct cedar-unified-dev --debug-port 0 now reaches the inspector helper.
  • The user-facing cedar dev --ud --apiDebugPort 0 flow can still replace 0 with a derived port.
  • The module import side effect appears resolved by moving startup out of the imported module.

packages/cli/src/commands/dev/apiDebugFlag.ts

Important Files Changed

Filename Overview
packages/vite/src/cedar-unified-dev.ts Adds argument parsing, inspector startup, debugger waiting, and exported helpers for unified dev mode.
packages/vite/src/tests/cedar-unified-dev.test.ts Adds unit coverage for CLI parsing and inspector helper behavior.
packages/cli/src/commands/dev.ts Adds the public debugBrk option for cedar dev.
packages/cli/src/commands/dev/devHandler.ts Forwards debugger flags into the unified dev child command.
tasks/ud-tests/udDev.test.mts Adds CDP helpers and end-to-end debugger tests for UD mode.
docs/implementation-docs/2026-06-29-debug-port-inspector-ud-mode.md Documents the implemented UD inspector flow and Vite SSR breakpoint behavior.
docs/implementation-plans/ud-debug-proxy-attach-breakpoints-plan.md Adds a follow-up plan for improving attach-workflow breakpoints through a debug proxy.
package.json Adds ws as a development dependency.
yarn.lock Updates the lockfile for the new development dependency.

Reviews (4): Last reviewed commit: "Merge branch 'main' into tobbe-feat-ud-d..." | Re-trigger Greptile

Comment thread packages/vite/src/cedar-unified-dev.ts Outdated
Comment thread packages/vite/src/__tests__/cedar-unified-dev.test.ts
@nx-cloud

nx-cloud Bot commented Jun 28, 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 37e66da

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

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-29 11:34:13 UTC

Comment thread packages/vite/src/cedar-unified-dev.ts Outdated
vi.spyOn(process, 'exit').mockImplementation(() => undefined as never)
vi.spyOn(console, 'error').mockImplementation(() => {})

const { parseCliArgs, openDebugger } = await import('../cedar-unified-dev.js')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Import Still Starts Server This import still evaluates cedar-unified-dev.ts and runs its module-level startUnifiedDevServer() call. The new spies prevent process.exit() and hide console.error, but startup still sets process.env.__CEDAR_UNIFIED_DEV = 'true' and only stops because the mocked config is incomplete enough to crash before Vite starts. That leaked env state can affect later tests, and any future mock that includes web.port can re-enter real dev-server startup during this unit test. Please guard the entrypoint so server startup only runs when the file is executed as the CLI binary.

const { forceOptimize, debug, portArg, debugPort, debugBrk, serverArgs } =
parseCliArgs()

if (debugPort !== undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Ephemeral Port Still Rewritten

This guard now preserves --debug-port 0 when cedar-unified-dev is started directly, but the normal cedar dev --ud --apiDebugPort 0 path can still rewrite the value before it gets here. devHandler builds the child command through getApiDebugFlag(apiDebugPort, apiAvailablePort), and that helper still treats numeric 0 as absent. When a user asks for an OS-assigned debug port through cedar dev --ud --apiDebugPort 0, the child receives the derived --debug-port 1<apiPort> value instead of --debug-port 0, so the explicit ephemeral-port request is not honored.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greptileai what's this "ephemeral port" you're talking about?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Ephemeral port" is a networking term for port 0. When you pass 0 as a port number to Node.js (or any TCP socket), the OS automatically picks any available port from its dynamic range (~49152–65535). It's useful when you don't care which specific port is used.

My original comment was flagging that if someone passed --apiDebugPort 0 intending OS-assigned port selection, getApiDebugFlag would silently ignore it — because if (apiDebugPort) treats 0 as falsy and falls through to the derived-port logic instead.

That said, looking at this PR again: it's about --debug-port for cedar-unified-dev directly, not --apiDebugPort. The if (debugPort !== undefined) guard in your changes is already correct. The getApiDebugFlag concern is pre-existing behavior unrelated to your changes, and passing 0 as a debug port is an obscure edge case no one is likely to hit.

You can safely ignore my original comment.

@Tobbe Tobbe merged commit e5103f6 into main Jun 29, 2026
51 checks passed
@Tobbe Tobbe deleted the tobbe-feat-ud-debug branch June 29, 2026 16:57
@github-actions

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.2566

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

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