question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preprocessor swallows errors and ignores ENOENT for bundled files

See original GitHub issue

bug

Cypress 3.0.1 on Mac

I have been playing with a spec preprocessor based on Parcel and noticed a curious thing. If the bundler is configured incorrectly and actually does NOT bundle files but returns a non-existing path, the test runner swallows the error and happily exits with code 0, while showing (and ignoring) ENOENT error

Example output

  Running: spec.js...                                                                      (1 of 1) 
bundle file once without watching to /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js
basename spec
bundle file once without watching to /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js
basename index
Error: ENOENT: no such file or directory, stat '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js'


Error: ENOENT: no such file or directory, stat '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js'


Error: ENOENT: no such file or directory, stat '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js'




  0 passing (2ms)


  (Results)

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Tests:        0         β”‚
  β”‚ Passing:      0         β”‚
  β”‚ Failing:      0         β”‚
  β”‚ Pending:      0         β”‚
  β”‚ Skipped:      0         β”‚
  β”‚ Screenshots:  0         β”‚
  β”‚ Video:        true      β”‚
  β”‚ Duration:     0 seconds β”‚
  β”‚ Spec Ran:     spec.js   β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


  (Video)

  - Started processing:   Compressing to 32 CRF
  - Finished processing:  /Users/gleb/git/cypress-example-recipes/examples/blogs__parcel_preprocessor/cypress/videos/spec.js.mp4 (0 seconds)


====================================================================================================

  (Run Finished)


      Spec                                                Tests  Passing  Failing  Pending  Skipped 
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ βœ” spec.js                                     3ms        -        -        -        -        - β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    All specs passed!                             3ms        -        -        -        -        -  

The bundles files are returned like this

const onFile = (file) => {
  const { filePath, shouldWatch, outputPath } = file
  if (!shouldWatch) {
    console.log('bundle file once without watching to %s', outputPath)
    return bundleOnce(filePath, outputPath).then(() => outputPath)
  }
  ...
}

Here is the relevant verbose logs

  cypress:server:socket watch test file integration/spec.js +0ms
  cypress:server:socket will watch test file path cypress/integration/spec.js +0ms
  cypress:server:preprocessor getFile /Users/gleb/git/cypress-example-recipes/examples/blogs__parcel_preprocessor/cypress/integration/spec.js +0ms
  cypress:server:appdata path: /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js +1ms
  cypress:server:plugins execute plugin event 'file:preprocessor' with args: EventEmitter { domain: null, _events: { rerun: [Function] }, _eventsCount: 1, _maxListeners: undefined, filePath: '/Users/gleb/git/cypress-example-recipes/examples/blogs__parcel_preprocessor/cypress/integration/spec.js', outputPath: '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js', shouldWatch: false } undefined undefined +0ms
  cypress:server:plugins call event file:preprocessor for invocation id inv1 +3ms
  cypress:server:plugins:child execute plugin event: file:preprocessor ({ eventId: 2, invocationId: 'inv1' }) +2s
bundle file once without watching to /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js
  cypress:server:controllers:spec request for cypress/support/index.js +12ms
  cypress:server:preprocessor getFile /Users/gleb/git/cypress-example-recipes/examples/blogs__parcel_preprocessor/cypress/support/index.js +1ms
  cypress:server:appdata path: /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js +0ms
  cypress:server:plugins execute plugin event 'file:preprocessor' with args: EventEmitter { domain: null, _events: { rerun: [Function] }, _eventsCount: 1, _maxListeners: undefined, filePath: '/Users/gleb/git/cypress-example-recipes/examples/blogs__parcel_preprocessor/cypress/support/index.js', outputPath: '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js', shouldWatch: false } undefined undefined +0ms
  cypress:server:plugins call event file:preprocessor for invocation id inv2 +1ms
  cypress:server:controllers:spec request for cypress/integration/spec.js +0ms
  cypress:server:preprocessor getFile /Users/gleb/git/cypress-example-recipes/examples/blogs__parcel_preprocessor/cypress/integration/spec.js +0ms
  cypress:server:preprocessor headless and already processed +0ms
  cypress:server:plugins:child execute plugin event: file:preprocessor ({ eventId: 2, invocationId: 'inv2' }) +52ms
bundle file once without watching to /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js
  cypress:server:plugins promise resolved for id 'inv1' with value /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js +444ms
  cypress:server:controllers:spec send /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js +0ms
Error: ENOENT: no such file or directory, stat '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js'


  cypress:server:plugins promise resolved for id 'inv2' with value /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js +5ms
  cypress:server:controllers:spec send /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js +0ms
Error: ENOENT: no such file or directory, stat '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/support/index.js'


  cypress:server:controllers:spec request for cypress/integration/spec.js +2ms
  cypress:server:preprocessor getFile /Users/gleb/git/cypress-example-recipes/examples/blogs__parcel_preprocessor/cypress/integration/spec.js +0ms
  cypress:server:preprocessor headless and already processed +0ms
  cypress:server:controllers:spec send /Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js +0ms
Error: ENOENT: no such file or directory, stat '/Users/gleb/Library/Application Support/Cypress/cy/production/projects/blogs__parcel_preprocessor-677867adc8d7253c8b90ac225b617bcd/bundles/cypress/integration/spec.js'


  cypress:server:timers clearing timer id 11 from queue { '11': { args: [], ms: 85000, cb: [Function] } } +5ms
  cypress:server:timers queuing timer id 12 after 85000 ms +0ms
  cypress:server:timers child received timer id 12 +474ms
  cypress:server:timers clearing timer id 12 from queue { '12': { args: [], ms: 85000, cb: [Function] } } +9ms
  cypress:server:timers queuing timer id 13 after 85000 ms +0ms
  cypress:server:project onSetRunnables +1ms
  cypress:server:timers child received timer id 13 +10ms
  cypress:server:project runnables null +0ms
  cypress:server:reporter trying to load reporter: spec +0ms
  cypress:server:reporter spec is Mocha reporter +0ms
  cypress:server:timers clearing timer id 13 from queue { '13': { args: [], ms: 85000, cb: [Function] } } +12ms
  cypress:server:timers queuing timer id 14 after 85000 ms +0ms
  cypress:server:timers child received timer id 14 +12ms
  cypress:server:project onMocha start +0ms
  cypress:server:reporter got mocha event 'start' with args: [ { start: '2018-06-05T03:35:06.763Z' } ] +1ms

  cypress:server:timers clearing timer id 14 from queue { '14': { args: [], ms: 85000, cb: [Function] } } +2ms
  cypress:server:timers queuing timer id 15 after 85000 ms +0ms
  cypress:server:project onMocha end +0ms
  cypress:server:timers child received timer id 15 +3ms
  cypress:server:reporter got mocha event 'end' with args: [ { end: '2018-06-05T03:35:06.766Z' } ] +0ms

  0 passing (2ms)

the folder was there, just the file that was supposed to be there does not exist when we return it from preprocessor

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
bahmutovcommented, Jun 5, 2018

Yes, but we are ignoring the error which is the wrong way to go about it. External code should be least trusted in this case.

Sent from my iPhone

On Jun 5, 2018, at 13:45, Chris Breiding notifications@github.com wrote:

Yeah, I guess we don’t validate the path returned to make sure there’s a file there. So it ends up 404ing in the browser which results in 0 tests. I suppose we should fs.stat the output path returned and fail if it’s not there. But to some degree we need to trust that the preprocessor does the right thing (like erroring when it can’t bundle). Because even if the file is there, it could be empty or not javascript or just not the right thing that should have been produced by your source spec file.

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

1reaction
bahmutovcommented, Jun 5, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

Nanoc Β» Release notes
Ignore redirects to self (misued for cookies) (#1496) [Daniel Aleksandersen]. 4.11.15 (2020-03-07). Enhancements: Made prune print files to delete when usingΒ ...
Read more >
MOTIF Frequently Asked Questions
113) What if I have problems with the backspace/delete keys? 114) How can I use a file as the text source for a...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/28 10 ...
... Bug:374475 - "nwn-data downloads 1.5GB of files only to tell me i need ... Bug:382827 - "sys-apps/portage-2.1.10.11 crashes with confusing error whenΒ ......
Read more >
Catatan Perubahan β€” Dokumentasi Python 3.8.14
bpo-44849: Fix the os.set_inheritable() function on FreeBSD 14 for file descriptor opened with the O_PATH flag: ignore the EBADF error on ioctl() ,...
Read more >
Changelog - Sphinx documentation
#10444: html theme: Allow specifying multiple CSS files through the stylesheet ... #10110: sphinx-build: exit code is not changed when error is raised...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found