Skip to content

feat(nuxi): add --portless for dev server#1301

Open
onmax wants to merge 7 commits intomainfrom
feat/nuxi-portless
Open

feat(nuxi): add --portless for dev server#1301
onmax wants to merge 7 commits intomainfrom
feat/nuxi-portless

Conversation

@onmax
Copy link
Copy Markdown
Contributor

@onmax onmax commented Apr 30, 2026

Adds nuxi dev --portless, precomputes the Portless hostname so Nuxt/Vite allowlists include it, and keeps the alias in sync across forked dev restarts.

Related: unjs/listhen#228

Closes #1300.

@onmax onmax requested a review from danielroe as a code owner April 30, 2026 06:59
Comment thread packages/nuxt-cli/test/e2e/dev.spec.ts Fixed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@onmax has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 39 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2309d740-b40a-47b0-bf43-b4ae177f4b42

📥 Commits

Reviewing files that changed from the base of the PR and between 7d5e691 and 16f9ce1.

📒 Files selected for processing (5)
  • packages/nuxi/src/commands/dev.ts
  • packages/nuxi/src/dev/portless.ts
  • packages/nuxi/test/unit/commands/dev.spec.ts
  • packages/nuxi/test/unit/dev/portless-exit.spec.ts
  • packages/nuxt-cli/test/e2e/dev.spec.ts
📝 Walkthrough

Walkthrough

Adds a --portless boolean option to the dev command that integrates with the external Portless CLI. Implements a new dev/portless.ts module to check availability, resolve a normalized project name, obtain a public URL, and register/remove portless aliases. The dev command validates --portless vs --tunnel, passes the public URL to listhen listener overrides, registers aliases for in-process and forked listeners, ensures cleanup on errors and shutdown, and includes unit and e2e tests for name resolution and end-to-end portless interactions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature: adding a --portless option to the dev command.
Description check ✅ Passed The description is directly related to the changeset, explaining the portless feature, hostname precomputation, and alias sync across forked restarts.
Linked Issues check ✅ Passed The PR fully implements the requirements from issue #1300: adds --portless option [#1300], enables Portless integration [#1300], supports hostname precomputation [#1300], and maintains alias sync across restarts [#1300].
Out of Scope Changes check ✅ Passed All changes are in scope: dev command option, portless utility module, and comprehensive unit/e2e tests directly support the --portless feature objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/nuxi-portless

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 12 minutes and 39 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/nuxi/src/commands/dev.ts`:
- Around line 104-128: If registerPortless or listener.showURL fails we
currently restore PORTLESS_URL and call close() but never remove a previously
created alias; modify the catch block around registerPortless/listener.showURL
to call removePortlessAlias(cwd, portlessName!) (awaiting it and ignoring
errors) before restoring process.env.PORTLESS_URL and rethrowing; ensure the
existing closePortless assignment (which also calls removePortlessAlias) remains
for the success path and reference registerPortless, closePortless,
removePortlessAlias, listener.showURL, close, and previousPortlessURL when
implementing the cleanup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7899ac77-5dc4-4f1f-bd7e-6cf32c2fc6e5

📥 Commits

Reviewing files that changed from the base of the PR and between a35d6d3 and 214ab48.

📒 Files selected for processing (4)
  • packages/nuxi/src/commands/dev.ts
  • packages/nuxi/src/dev/portless.ts
  • packages/nuxi/test/unit/dev/portless.spec.ts
  • packages/nuxt-cli/test/e2e/dev.spec.ts

Comment thread packages/nuxi/src/commands/dev.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 30, 2026

  • nuxt-cli-playground

    npm i https://pkg.pr.new/create-nuxt@1301
    
    npm i https://pkg.pr.new/nuxi@1301
    
    npm i https://pkg.pr.new/@nuxt/cli@1301
    

commit: 16f9ce1

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 30, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing feat/nuxi-portless (16f9ce1) with main (a35d6d3)

Open in CodSpeed

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/nuxt-cli/test/e2e/dev.spec.ts`:
- Around line 99-107: The extractLoggedURLs function returns raw matches that
may include formatting artifacts or trailing slashes causing flaky CI
assertions; update extractLoggedURLs to normalize each URL before returning by
trimming whitespace, stripping ANSI escape sequences, removing surrounding
punctuation (like trailing ')' or '.'), and trimming a single trailing slash
(and optionally lowercasing) so comparisons are consistent; keep the function
name extractLoggedURLs and apply normalization to every match returned from
value.match(...) so tests comparing those URLs are stable.
- Around line 173-196: The test currently calls await close() inside the try
block so a thrown assertion can leak the spawned dev process; refactor to
capture the close function from runCommand into an outer-scoped variable (e.g.,
let close: (() => Promise<void>) | undefined), assign it when runCommand
resolves, and then in the finally block await close() if defined before
restoring consoleLog.mockRestore() and removing binDir; reference runCommand and
the close function to locate where to move the cleanup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3cb523d0-edc2-49db-b161-68f2d2e7db57

📥 Commits

Reviewing files that changed from the base of the PR and between 214ab48 and 7d5e691.

📒 Files selected for processing (4)
  • packages/nuxi/src/commands/dev.ts
  • packages/nuxi/src/dev/portless.ts
  • packages/nuxi/test/unit/commands/dev.spec.ts
  • packages/nuxt-cli/test/e2e/dev.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/nuxi/src/dev/portless.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/nuxi/src/commands/dev.ts

Comment on lines +99 to +107
function extractLoggedURLs(calls: unknown[][]) {
return calls.flatMap(call => call.flatMap((value) => {
if (typeof value !== 'string') {
return []
}

return value.match(/https?:\/\/[^\s)]+/g) || []
}))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Normalize logged URLs before assertion to fix CI flake/failure.

The current equality check is too strict for logged output; extracted URLs can include formatting artifacts or a trailing slash, which matches the CI failure at Line 190.

💡 Suggested patch
 function extractLoggedURLs(calls: unknown[][]) {
   return calls.flatMap(call => call.flatMap((value) => {
     if (typeof value !== 'string') {
       return []
     }

-    return value.match(/https?:\/\/[^\s)]+/g) || []
+    const cleaned = value.replace(/\u001B\[[0-9;]*m/g, '')
+    return (cleaned.match(/https?:\/\/[^\s)]+/g) || []).map(url => url.replace(/\/$/, ''))
   }))
 }
@@
-      expect(extractLoggedURLs(consoleLog.mock.calls)).toContain(portlessURL)
+      expect(extractLoggedURLs(consoleLog.mock.calls)).toContain(portlessURL.replace(/\/$/, ''))

Also applies to: 190-190

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/nuxt-cli/test/e2e/dev.spec.ts` around lines 99 - 107, The
extractLoggedURLs function returns raw matches that may include formatting
artifacts or trailing slashes causing flaky CI assertions; update
extractLoggedURLs to normalize each URL before returning by trimming whitespace,
stripping ANSI escape sequences, removing surrounding punctuation (like trailing
')' or '.'), and trimming a single trailing slash (and optionally lowercasing)
so comparisons are consistent; keep the function name extractLoggedURLs and
apply normalization to every match returned from value.match(...) so tests
comparing those URLs are stable.

Comment thread packages/nuxt-cli/test/e2e/dev.spec.ts
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.

Add --portless option for remote dev access

2 participants