Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(testing): add timeout to runCommandUntil to prevent hanging tests#34148

Merged
FrozenPandaz merged 15 commits intomasterfrom
fix/add-timeout-to-runCommandUntil
Jan 30, 2026
Merged

fix(testing): add timeout to runCommandUntil to prevent hanging tests#34148
FrozenPandaz merged 15 commits intomasterfrom
fix/add-timeout-to-runCommandUntil

Conversation

@FrozenPandaz
Copy link
Collaborator

Current Behavior

The runCommandUntil e2e utility function waits indefinitely for the expected output to appear. If the output never appears (e.g., server fails to start, different output format, port conflict), the test hangs forever, causing CI jobs to run for hours before being killed.

Expected Behavior

The function should timeout after a configurable duration and fail with a clear error message showing what output was received.

Related Issue(s)

Fixes hanging e2e tests observed in CI (e.g., e2e-node:e2e-ci--src/node-server.test.ts hung for 1h 21m).

Changes

  • Added optional timeout parameter to runCommandUntil opts (default: 5 seconds)
  • On timeout: kills the process, logs the collected output, and rejects with a clear error
  • Existing call sites work unchanged; tests needing more startup time can pass { timeout: 30000 }

@vercel
Copy link

vercel bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nx-dev Ready Ready Preview Jan 30, 2026 1:26am

Request Review

@netlify
Copy link

netlify bot commented Jan 19, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 75a59a7
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/697c0744766afa00081ec3b4
😎 Deploy Preview https://deploy-preview-34148--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit 75a59a7

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 13m 31s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 57s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 11s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-30 03:30:44 UTC

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
Copy link
Collaborator Author

@copilot Can you update the global-setup.ts file in e2e-utils to use environment variables rather than the npm config commands so that the setup and teardown do not polute other e2e tests which may be running?

Copy link
Contributor

Copilot AI commented Jan 28, 2026

@FrozenPandaz I've opened a new pull request, #34240, to work on those changes. Once the pull request is ready, I'll request review from you.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

Copilot AI and others added 12 commits January 29, 2026 20:19
## Current Behavior

The `runCommandUntil` e2e utility waits indefinitely for expected
output, causing tests to hang for hours in CI when servers fail to start
or produce different output. Additionally, `global-setup.ts` uses `npm
config set/delete` commands that modify global npm configuration,
polluting concurrent e2e test environments.

## Expected Behavior

Tests should timeout with clear error messages, and e2e setup should not
interfere with parallel test execution.

## Changes

### runCommandUntil timeout

- Added optional `timeout` parameter (default: 5 seconds)
- On timeout: kills process, logs collected output, rejects with
descriptive error
- Updated tests requiring longer startup time to pass explicit timeout
values

```typescript
// Existing tests work unchanged with 5s default
await runCommandUntil(`nx serve app`, (output) => output.includes('ready'));

// Tests needing more time specify explicit timeout
await runCommandUntil(`nx serve app`, (output) => output.includes('ready'), {
  timeout: 30000
});
```

### global-setup environment isolation

- Replaced `execSync('npm config set ...')` with
`process.env['npm_config_//localhost:4873/:_authToken']`
- Replaced `execSync('npm config delete ...')` with `delete
process.env[...]` in teardown
- Removed unnecessary `npm config get registry` diagnostic call
- Environment variables are process-scoped and don't affect concurrent
test runs

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: FrozenPandaz <[email protected]>
Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

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

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We removed the explicit Gradle daemon stop command from the test setup to fix the race condition where daemons were being terminated during active test execution. This change prevents the "Gradle build daemon has been stopped: stop command received" error by allowing daemons to run continuously throughout the test suite.

Warning

We could not verify this fix.

diff --git a/e2e/gradle/src/utils/create-gradle-project.ts b/e2e/gradle/src/utils/create-gradle-project.ts
index e7bcdceea8..2f768684f3 100644
--- a/e2e/gradle/src/utils/create-gradle-project.ts
+++ b/e2e/gradle/src/utils/create-gradle-project.ts
@@ -48,11 +48,8 @@ export function createGradleProject(
   }
 
   try {
-    e2eConsoleLogger(
-      runCommand(`${gradleCommand} --stop`, {
-        cwd,
-      })
-    );
+    // Run clean without stopping daemons first to avoid race conditions
+    // where subsequent test executions try to use a daemon that's being stopped
     e2eConsoleLogger(
       runCommand(`${gradleCommand} clean`, {
         cwd,

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally xYs1-plzG

Apply fix locally with your editor ↗   View interactive diff ↗


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz FrozenPandaz marked this pull request as ready for review January 30, 2026 05:07
@FrozenPandaz FrozenPandaz requested review from a team, meeroslav and vsavkin as code owners January 30, 2026 05:07
@FrozenPandaz FrozenPandaz merged commit d9f2ed0 into master Jan 30, 2026
21 of 22 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/add-timeout-to-runCommandUntil branch January 30, 2026 05:18
jaysoo pushed a commit that referenced this pull request Jan 30, 2026
…#34148)

## Current Behavior

The `runCommandUntil` e2e utility function waits indefinitely for the
expected output to appear. If the output never appears (e.g., server
fails to start, different output format, port conflict), the test hangs
forever, causing CI jobs to run for hours before being killed.

## Expected Behavior

The function should timeout after a configurable duration and fail with
a clear error message showing what output was received.

## Related Issue(s)

Fixes hanging e2e tests observed in CI (e.g.,
`e2e-node:e2e-ci--src/node-server.test.ts` hung for 1h 21m).

## Changes

- Added optional `timeout` parameter to `runCommandUntil` opts (default:
5 seconds)
- On timeout: kills the process, logs the collected output, and rejects
with a clear error
- Existing call sites work unchanged; tests needing more startup time
can pass `{ timeout: 30000 }`

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: FrozenPandaz <[email protected]>
Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
Co-authored-by: FrozenPandaz <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants