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

Long-running processes fail with Error: ENOENT: no such file or directory #33

Closed
jordanandree opened this issue Jan 6, 2023 · 11 comments
Labels

Comments

@jordanandree
Copy link

First off, thanks for this great library!

When setting it up for an existing cypress project, I've noticed that some files that take a while to preprocess will throw an error in the Cypress runner output window:

Error: ENOENT: no such file or directory, stat '/Users/<user>/Library/Application Support/Cypress/cy/production/projects/<project-hash>/bundles/cypress/e2e/<spec>.cy.ts'

After a few minutes of waiting, it seems that Vite builds the file and emits an event for Cypress to rerun, which then it succeeds. I'm wondering if there are some improvements that can be made to the watcher for the preprocessor, but I'm not super familiar with Cypress file preprocessors.

Here is a rough diff for the final return of the process here. I was able to working locally that checks if the ouputFile is ready or otherwise will throw an error. Ideally it would be nice to have Cypress wait longer before outputting anything but I couldn't figure that out:

-    cache[filePath] = outputPath
-    debug("Bundle for file %s cached at %s", filePath, outputPath)
-    return outputPath
+
+    if (fs.existsSync(outputPath)) {
+      cache[filePath] = outputPath
+      debug("Bundle for file %s cached at %s", filePath, outputPath)
+      return outputPath
+    }
+
+    if (shouldWatch) {
+      debug("Bundle not ready while compiling original file %s", filePath)
+      throw Error("Bundle not ready while compiling original file")
+    } else {
+      return filePath
+    }

System info:

  Binaries:
    Node: 16.15.0 
    Yarn: 1.22.18
    npm: 8.8.0
    typescript: 4.7.2
  Browsers:
    Chrome: 108.0.5359.124
@mammadataei
Copy link
Owner

Hi @jordanandree, thanks for reaching out.
Recently, I experienced the same delay on the first run in one of my projects and it was because of a not-optimized dependency in the app. Obviously, in my case, it wasn't the tests that caused the problem. I'm not sure, but maybe in your case, there is a test utility or some third party that is causing the issue. Can you check to see whether this is true? Or maybe a Vite plugin is causing the issue?

I don't think throwing error is the right way to solve this. I'll try to figure out some way for triggering a rerun when the bundle is ready. And btw, more information about the tests, configuration, etc., or perhaps a reproduction can help me through this.

@snagasawa
Copy link

Hi, thanks for great library like this ! :)

I got same error.
Execute npx cypress open and run e2e test, then Cypress Studio shows the following error.

Error: ENOENT: no such file or directory, stat '/Users/<user>/Library/Application Support/Cypress/cy/production/projects/front-7a0bead4da052e7d0236bfff078df7a5/bundles/cypress/e2e/xxx/xxx.cy.ts

This file exists surely but has extention .ts.js not .ts.

/Users/<user>/Library/Application Support/Cypress/cy/production/projects/front-7a0bead4da052e7d0236bfff078df7a5/bundles/cypress/e2e/xxx/xxx.cy.ts.js

Why and how to fix it ?


  • cypress.config.ts
import { defineConfig } from 'cypress'
import vitePreprocessor from 'cypress-vite'
import path from 'path'

export default defineConfig({
  viewportWidth: 1000,
  viewportHeight: 1200,
  video: false,
  screenshotOnRunFailure: false,
  e2e: {
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    setupNodeEvents(on) {
      on('file:preprocessor', vitePreprocessor(path.resolve(__dirname, './vite.config.ts')))
    },
    baseUrl: 'http://localhost:8082',
  },
})
  • Versions
    • Node: 16.17.0
    • Cypress: 12.13.0
    • TypeScript: 4.9.4
    • vite: 4.0.4
    • cypress-vite: 1.3.0

@oren-legit
Copy link

snagasawa I am experiencing the exact same problem! I think there is an actual issue with this library but I can't seem to fix it. If anyone knows how to fix this please say

@oren-legit
Copy link

@jordanandree @snagasawa Cypress version 10.11 seems to solve this (with Node 17).

@mammadataei
Copy link
Owner

@jordanandree @snagasawa do you confirm that Cypress@10.11 solves this?

@snagasawa
Copy link

@oren-legit @mammadataei
Cypress version 10.11 solve this error, although different issue occurred. Thanks. :)
v11.2 still got error.

@mammadataei
Copy link
Owner

@snagasawa same error on v11.2?! If so, could you please send me the debug output?
Feel free to open a new issue if you are facing a new error; I'll do my best to resolve it.

@MartinN3
Copy link

MartinN3 commented Feb 15, 2023

I had same error, no output from debug. Then i matched versions, tsconfigs and vite configs to this example repo.
Then i got error:
RollupError: Invalid value for option "output.manualChunks" - this option is not supported for "output.inlineDynamicImports".

after removing this piece of code from my vite.config.ts it started working.

@M4RcB4
Copy link

M4RcB4 commented Feb 16, 2023

@MartinN3 Can you clarify in what file and what code you removed to get this working?

@github-actions
Copy link
Contributor

This issue is automatically marked as stale because it has been open for 30 days with no activity. Remove the stale label or leave a comment, or it will be closed in 14 days.

@github-actions github-actions bot added the stale label Mar 19, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

This issue was closed because it has been stalled for 14 days with no activity. Please feel free to open a new issue if you have any further questions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants