test(nuxt): Wait for the dev port to be available#18736
test(nuxt): Wait for the dev port to be available#18736
Conversation
s1gr1d
left a comment
There was a problem hiding this comment.
I don't think that this will fix that - I'm also working on this right now (I introduced this problem 🙈 ).
I was under the assumption that playwright will wait for the port 3030 to start testing. But it seems like playwright already starts testing when only the temporary port 3035 is available.
| # 5. Wait for port 3030 to be ready before Playwright starts running tests | ||
| echo "Waiting for port 3030 to be ready..." | ||
| COUNTER=0 | ||
| while ! nc -z localhost 3030 2>/dev/null && [ $COUNTER -lt 60 ]; do |
There was a problem hiding this comment.
Bug: The script uses nc -z to check for an open port, but nc is not installed in the CI environment (ubuntu-24.04), causing the check to fail silently and wait for a full 30-second timeout.
Severity: HIGH | Confidence: High
🔍 Detailed Analysis
The bash script nuxt-start-dev-server.bash uses nc -z within a while loop to check if the dev server port is available. However, the netcat (nc) utility is not installed by default on the CI runner's operating system, ubuntu-24.04. When nc is not found, the command fails with exit code 127. The loop condition ! nc -z ... evaluates this failure as true, causing the loop to always run for its full 30-second duration, regardless of the server's actual status. This introduces a mandatory 30-second delay and can lead to flaky test failures if tests begin before the server is truly ready.
💡 Suggested Fix
Replace the nc -z command with a more reliable method that does not depend on a non-default utility. For instance, the script already uses lsof -i :$PORT in other places, which is more likely to be available. Alternatively, add a step to the CI workflow to install netcat (sudo apt-get install -y netcat-openbsd) before the script is run.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: dev-packages/e2e-tests/test-applications/nuxt-4/nuxt-start-dev-server.bash#L55
Potential issue: The bash script `nuxt-start-dev-server.bash` uses `nc -z` within a
`while` loop to check if the dev server port is available. However, the `netcat` (`nc`)
utility is not installed by default on the CI runner's operating system, `ubuntu-24.04`.
When `nc` is not found, the command fails with exit code 127. The loop condition `! nc
-z ...` evaluates this failure as `true`, causing the loop to always run for its full
30-second duration, regardless of the server's actual status. This introduces a
mandatory 30-second delay and can lead to flaky test failures if tests begin before the
server is truly ready.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8338389
|
I think this PR can be closed in favor of this one: #18737 |
closes #18728
closes JS-1422
Not sure if this is the correct way of doing that, but it seems the tests were failing for Nuxt 4 canary, but only the dev ones. Locally at least with that fix it wasn't flaky anymore.