nuxt / test-utils

🧪 Test utilities for Nuxt
http://nuxt.com/docs/getting-started/testing
MIT License
323 stars 84 forks source link

Server process not killed after upgrading to v3.13.2 #948

Closed peralta closed 1 month ago

peralta commented 2 months ago

Environment

Nuxt project info:                                                    20:43:02

------------------------------
- Operating System: Linux
- Node Version:     v18.20.4
- Nuxt Version:     3.13.2
- CLI Version:      3.13.2
- Nitro Version:    2.9.7
- Package Manager:  npm@10.7.0
- Builder:          -
- User Config:      devtools, devServer, site, experimental, nitro, modules, purgecss, gtag, notivue, fonts, icon, routeRules, sitemap, plugins, css, vite, app, compatibilityDate
- Runtime Modules:  @nuxtjs/eslint-module@4.1.0, @nuxt/content@2.13.2, nuxt-time@0.1.3, nuxt-gtag@3.0.1, notivue/nuxt, @nuxtjs/sitemap@5.3.5, @nuxt/image@1.8.0, nuxt-jsonld@2.0.8, @nuxt/fonts@0.7.2, nuxt-purgecss@2.0.0, @nuxt/icon@1.5.1
- Build Modules:    -
------------------------------

Reproduction

After upgrading nuxt v3.13.2 from v3.13.1, which triggered the dependency update from test-utils to the same version, the first test node server process is not killed. Following tests fail because address is already in use.

Describe the bug

Downgrading test-utils to v3.13.1 fixes the issue. Probably related to the tinyexec PR: https://github.com/nuxt/test-utils/pull/939

Additional context

No response

Logs

No response

dosubot[bot] commented 2 months ago

Hey there, @peralta! I'm Dosu, a bot designed to help you with bug fixes, questions, and becoming a contributor. I'm here to assist you while waiting for a human maintainer. Let's squash those bugs together! 🤖

The issue you're experiencing with the server process not being killed after upgrading to Nuxt v3.13.2 is indeed related to the introduction of tinyexec in test-utils. The tinyexec implementation is not properly handling the termination of processes, which causes the server process to linger and subsequent tests to fail due to the address being in use.

In the startServer function, tinyexec is used to start the server process, but if the server is not properly stopped using the stopServer function, which calls ctx.serverProcess.kill(), the process remains running. This issue likely stems from tinyexec not correctly handling the termination of the server process [1][2].

Downgrading to test-utils v3.13.1, which uses execa instead of tinyexec, resolves the issue because execa handles process termination more reliably. You can follow the discussion and potential fixes in the related pull request here.

To continue talking to Dosu, mention @dosu.

peralta commented 1 month ago

False positive