-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat(vite-dev-server): migrate to async fs operations for better perf… #33024
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
base: develop
Are you sure you want to change the base?
Conversation
…ormance - Replace fs.readFileSync with async fs.readFile - Add proper error handling with debug logs - Improve performance by avoiding event loop blocking - Remove TODO comment about async fs methods This follows Node.js best practices and improves DX with faster build times.
|
…nction for lazy loading
… into feat/vite-async-fs
… into feat/vite-async-fs
| let loader = fs.readFileSync(INIT_FILEPATH, 'utf8') | ||
|
|
||
| // Load the init file asynchronously with proper error handling | ||
| const loadInitFile = async (): Promise<string> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucgonp Do you have any performance benchmarks to share to show the improved performance here? I feel like there needs to be a tangible benefit here to measure given the increase in code complexity.
Is there a reason we need to have the promise be a singleton. I'm guessing there is some type of race condition when loading the file?
…ormance
This follows Node.js best practices and improves DX with faster build times.
Additional details
Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?Note
Switches to fs/promises, asynchronously loads/caches the init script with error handling, and updates index.html reading to async.
npm/vite-dev-server/src/plugins/cypress.ts):fs.readFileSyncwith asyncfs.readFileviafs/promises; update index.html reading tofs.readFile.loadInitFilewith debug logging and robust error handling; introduce cachedloaderPromisewith reset on failure.transformIndexHtml: await cached loader content and inject it into the generated HTML.Written by Cursor Bugbot for commit 407e79e. This will update automatically on new commits. Configure here.