Skip to content

Conversation

@lucgonp
Copy link

@lucgonp lucgonp commented Nov 26, 2025

…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.

  • Closes

Additional details

Steps to test

How has the user experience changed?

PR Tasks


Note

Switches to fs/promises, asynchronously loads/caches the init script with error handling, and updates index.html reading to async.

  • Vite dev server plugin (npm/vite-dev-server/src/plugins/cypress.ts):
    • Replace sync fs.readFileSync with async fs.readFile via fs/promises; update index.html reading to fs.readFile.
    • Add loadInitFile with debug logging and robust error handling; introduce cached loaderPromise with 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.

…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.
@cypress-app-bot
Copy link
Collaborator

@lucgonp lucgonp marked this pull request as draft November 28, 2025 16:54
@lucgonp lucgonp marked this pull request as ready for review November 28, 2025 16:54
let loader = fs.readFileSync(INIT_FILEPATH, 'utf8')

// Load the init file asynchronously with proper error handling
const loadInitFile = async (): Promise<string> => {
Copy link
Contributor

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?

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.

4 participants