Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update vite #5311

Merged
merged 19 commits into from
Apr 6, 2024
Merged

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Feb 29, 2024

Description

Related #5123 (comment), #5193

I tweaked vite-node watch test cases with a quick workaround. I'll see how others go on CI.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Feb 29, 2024

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit d2ac106
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/6610a6a7e737fd0008786370
😎 Deploy Preview https://deploy-preview-5311--fastidious-cascaron-4ded94.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 site configuration.

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Mar 1, 2024

Maybe flakiness increased or maybe it's just same as before. I retried three times and Windows CI hasn't go through yet.
https://github.com/vitest-dev/vitest/actions/runs/8106298865?pr=5311

@sheremet-va
Copy link
Member

sheremet-va commented Mar 1, 2024

Maybe flakiness increased or maybe it's just same as before. I retried three times and Windows CI hasn't go through yet.

https://github.com/vitest-dev/vitest/actions/runs/8106298865?pr=5311

Yea, it increased. I have another PR open with this change and it's not merged because of the flakiness. We need to rewrite the waitForWatcher to wait for a specific file. The watcher emits ready event too soon.

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Mar 1, 2024

The watcher emits ready event too soon.

@sheremet-va Do you know where this change is coming from? I couldn't find any specific change on Vite, so maybe something from chokidar (bumped to 3.6.0 in vitejs/vite#15803)?

@sheremet-va
Copy link
Member

The watcher emits ready event too soon.

@sheremet-va Do you know where this change is coming from? I couldn't find any specific change on Vite, so maybe something from chokidar (bumped to 3.6.0 in vitejs/vite#15803)?

Could be anything, I don't know why this started happening, but watcher was always unstable.

@sheremet-va
Copy link
Member

Maybe we can pass down a ENV variable and wait for it to appear in watcher.getWatched()? Like here: https://github.com/vitejs/vite/blob/63a39c244b08cf1f2299bc2c3cfddcb82070d05b/playground/hmr-ssr/__tests__/hmr.spec.ts#L971

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Mar 4, 2024

Thanks for the pointer. I didn't know you were referring watcher.getWatched() when you were talking about vite runtime tests #5123 (comment).

For vite-node tests, we can wait for entry files to be included watcher.getWatched(), but I'm not sure what we should target for Vitest watch tests.

@sheremet-va
Copy link
Member

sheremet-va commented Mar 4, 2024

For vite-node tests, we can wait for entry files to be included watcher.getWatched(), but I'm not sure what we should target for Vitest watch tests.

We can use something like this VITEST_TEST_WATCHER_FILE=filename vitest run

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Mar 6, 2024

We can use something like this VITEST_TEST_WATCHER_FILE=filename vitest run

Failing CI is indicating that runVitestCli is stuck before outputting Waiting for file changes:

https://github.com/vitest-dev/vitest/actions/runs/8135325279/job/22229683329#step:10:977

if (args.includes('--watch')) {
if (command === 'vitest') // Wait for initial test run to complete
await cli.waitForStdout('Waiting for file changes')
// make sure watcher is ready
await cli.waitForStdout('[debug] watcher is ready')
cli.stdout = cli.stdout.replace('[debug] watcher is ready\n', '')

So, I'm not sure if this flakiness can be fixed by waiting any specific file by VITEST_TEST_WATCHER_FILE=filename.

It maybe simply some performance degradation which makes Windows vmThreads harder to pass?

@@ -131,6 +131,31 @@ async function run(files: string[], options: CliOptions = {}) {
process.on('uncaughtException', (err) => {
console.error(c.red('[vite-node] Failed to execute file: \n'), err)
})

if (process.env.VITE_TEST_WATCHER_DEBUG) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add process.env.VITE_TEST_WATCHER_DEBUG: false in rollup config (under a condition like "production" build) so this is removed when bundling?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like I can use process.env.ROLLUP_WATCH to remove this only on build 17aa695

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, this obviously breaks CI since it uses build... Let me think about a different way.

@sheremet-va
Copy link
Member

Failing CI is indicating that runVitestCli is stuck before outputting Waiting for file changes:

This error happens more on Mac OS, to be honest. For some reason, this line is not reported at all.

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Mar 28, 2024

Failing CI is indicating that runVitestCli is stuck before outputting Waiting for file changes:

This error happens more on Mac OS, to be honest. For some reason, this line is not reported at all.

While searching I noticed this one VITE_TEST_WATCHER_DEBUG, I noticed this darwin specific one:

// chokidar fsevents is unstable on macos when emitting "ready" event
if (process.platform === 'darwin' && process.env.VITE_TEST_WATCHER_DEBUG) {
return {
server: {
watch: {
useFsEvents: false,
usePolling: false,
},

Also on Vitest side:

// chokidar fsevents is unstable on macos when emitting "ready" event
if (process.platform === 'darwin' && process.env.VITE_TEST_WATCHER_DEBUG) {
config.server!.watch!.useFsEvents = false
config.server!.watch!.usePolling = false
}

Maybe tweak this to see if it helps anything?

@hi-ogawa hi-ogawa changed the title chore(deps): update vite 5.1.4 chore(deps): update vite Apr 1, 2024
@sheremet-va
Copy link
Member

@hi-ogawa do you think this is stable enough?

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Apr 6, 2024

do you think this is stable enough?

Ubuntu and macos CI seems okay. I cannot really judge Windows behavior, so I can only hope it's stable enough.

@hi-ogawa hi-ogawa marked this pull request as ready for review April 6, 2024 01:59
@sheremet-va sheremet-va merged commit 75f48ba into vitest-dev:main Apr 6, 2024
18 of 19 checks passed
@hi-ogawa hi-ogawa deleted the chore-vite-5.1.4 branch April 6, 2024 07:57
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