Closed christian-bromann closed 1 year ago
I'm not sure how this can be fixed because clearing require
is needed to re-read the config. IIUC WebdriverIO spawns a Vite server here, would using cp.spawn
or execa
help with this quirk? since it feels like a Nodejs bug. Otherwise I think it's good to encourage "type": "module"
too to avoid CJS. Most of Vite starters now are ESM-first.
Otherwise I think it's good to encourage
"type": "module"
too to avoid CJS. Most of Vite starters now are ESM-first.
The ecosystem is moving slow so not all users have been migrated their projects to ESM but you are right, most of the Vite users likely use ESM anyway so I feel like the amount of folks running into this is low.
would using
cp.spawn
orexeca
help with this quirk?
Yes, if I start Vite this way it works. I guess I can just check for the environment and one or the other. I will close this as I think it is easier to workaround it on my side than fixing it on Vite. Thanks for the feedback.
Describe the bug
Hi 👋 I am maintaining a Vite plugin for WebdriverIO to start a Vite server as part of a setup routine to test ones application. I am running into an issue when trying to start a Vite server alongside another process.
The procedure is as follows:
I traced it down to the following code snippet: https://github.com/vitejs/vite/blob/9885f6f113667c1e161dee5f30af1e91aeefa62f/packages/vite/src/node/config.ts#L1101-L1103:
It seems like caching the require cache causes Node to garbage collect the Chromedriver plugin causing the started Chromedriver process to shut down. The Chromedriver plugins runs as ESM code but the project I am working on is CJS (e.g. the
vite.config.ts
is CJS).Reproduction
n/a
Steps to reproduce
npm install
npm run wdio:applitools
You see in the logs that Chromedriver starts on port
9515
by the Chromedriver service as well as Vite server start successfully. However when the WebDriver session is being initialised, port9515
is not accessible anymore.System Info
Used Package Manager
npm
Logs
Validations