Skip to content

fix(e2e): add explanation if server exited before being ready - #1761

Open
TheAlexLichter wants to merge 4 commits into
nuxt:mainfrom
TheAlexLichter:fix/explain-early-server-exit
Open

fix(e2e): add explanation if server exited before being ready#1761
TheAlexLichter wants to merge 4 commits into
nuxt:mainfrom
TheAlexLichter:fix/explain-early-server-exit

Conversation

@TheAlexLichter

Copy link
Copy Markdown
Member

🔗 Linked issue

None!

📚 Description

As the titles says. Adds more debug information if the server dies unexpectedly before being used.

@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/test-utils@1761
npm i https://pkg.pr.new/vitest-environment-nuxt@1761

commit: 5e78fe1

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e790bd65-7c86-4ffa-9d51-bfcb5864faba

📥 Commits

Reviewing files that changed from the base of the PR and between 95f6694 and 5e78fe1.

📒 Files selected for processing (1)
  • src/e2e/server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/e2e/server.ts

📝 Walkthrough

Walkthrough

The E2E server module imports the TestContext type and tracks asynchronous server-log collection. The startup path records elapsed time and flushes captured logs. When the server exits before readiness or during readiness polling, it reports exit status, kill state, server mode, elapsed time, and recent or unavailable output.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the added diagnostics for servers that exit before becoming ready.
Description check ✅ Passed The description explains that the change adds debug information when the server exits before use.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/e2e/server.ts`:
- Around line 133-136: Before the final stopServer() and timeout/lastError throw
path in the server startup wait flow, re-check ctx.serverProcess using the same
killed-or-non-null-exitCode predicate used in the loop. If the process has
exited, throw earlyExitError(ctx, { dev, elapsed: Date.now() - startedAt }) so
process diagnostics take precedence over the fallback error.
- Around line 113-121: Update the early-exit error construction around
ctx.serverLogs and waitForPort() to await the detached log collector before
formatting output. Preserve any collector error, and report it separately from
the server-exit message instead of classifying failed or incomplete capture as
no output; only use the existing no-output branches when collection completed
successfully.
- Around line 105-110: Update the early server-exit handling around
ctx.serverProcess to detect signal termination via
ctx.serverProcess.process?.signalCode ?? null, alongside the existing exit
conditions. Include the signal code in the details diagnostic, while preserving
the current exitCode and killed information.
🪄 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 Plus

Run ID: a5ef7326-eacc-4e7d-b5b2-9af97e15b7d7

📥 Commits

Reviewing files that changed from the base of the PR and between d32cec1 and 95f6694.

📒 Files selected for processing (1)
  • src/e2e/server.ts

Comment thread src/e2e/server.ts
Comment thread src/e2e/server.ts
Comment thread src/e2e/server.ts
@danielroe

Copy link
Copy Markdown
Member

@TheAlexLichter what do you make of the coderabbit suggestions?

@TheAlexLichter TheAlexLichter self-assigned this Aug 1, 2026
@TheAlexLichter

Copy link
Copy Markdown
Member Author

@danielroe resolved them!

Comment thread src/e2e/server.ts
const globalFetch = globalThis.fetch || _fetch

/** Resolves once the server's output has been fully collected into `ctx.serverLogs`. */
let serverLogsCollected: Promise<void> | undefined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be on the test context instead? it's possible to start multiple servers in a single test

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.

2 participants