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

"Error: Insufficient frames captured to create video." warning root cause #31046

Open
ahayes91 opened this issue Feb 7, 2025 · 2 comments
Open

Comments

@ahayes91
Copy link

ahayes91 commented Feb 7, 2025

Current behavior

Hi there!

We've seen an intermittent error Error: Insufficient frames captured to create video in a few of our Cypress Cloud runs for very short tests (the test where this happens runs an API request in Cypress and verifies the results match a static array we have in our code, used for checking some particular values exist on a test environment):

[2025-02-07T09:25:41.939Z]   1 passing (502ms)
[2025-02-07T09:25:46.101Z] Warning: We failed capturing this video.
[2025-02-07T09:25:46.101Z] 
[2025-02-07T09:25:46.101Z] This error will not affect or change the exit code.
[2025-02-07T09:25:46.101Z] 
[2025-02-07T09:25:46.101Z] Error: Insufficient frames captured to create video.
[2025-02-07T09:25:46.101Z]     at ChildProcess.<anonymous> (<embedded>:804:16306)
[2025-02-07T09:25:46.101Z]     at ChildProcess.emit (node:events:518:28)
[2025-02-07T09:25:46.101Z]     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
[2025-02-07T09:25:46.101Z] An error was thrown in your plugins file while executing the handler for the after:spec event.
[2025-02-07T09:25:46.101Z] 
[2025-02-07T09:25:46.101Z] The error we received was:
[2025-02-07T09:25:46.101Z] 
[2025-02-07T09:25:46.101Z] Error: ENOENT: no such file or directory, unlink '/home/jenkins/workspace/our_repo@2/packages/e2e/videos/checkAllValuesExist.cy.ts.mp4'
[2025-02-07T09:25:46.101Z]     at Module.unlinkSync (node:fs:1878:11)
[2025-02-07T09:25:46.101Z]     at Object.handler (file:///home/jenkins/workspace/our_repo@2/packages/e2e/cypress.config.ts:47:28)
[2025-02-07T09:25:46.101Z]     at invoke (/home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:185:18)
[2025-02-07T09:25:46.101Z]     at /home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:59:14
[2025-02-07T09:25:46.101Z]     at tryCatcher (/home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
[2025-02-07T09:25:46.101Z]     at Promise.attempt.Promise.try (/home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/bluebird/js/release/method.js:39:29)
[2025-02-07T09:25:46.101Z]     at Object.wrapChildPromise (/home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:58:23)
[2025-02-07T09:25:46.101Z]     at RunPlugins.execute (/home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:164:21)
[2025-02-07T09:25:46.101Z]     at EventEmitter.<anonymous> (/home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:56:12)
[2025-02-07T09:25:46.101Z]     at EventEmitter.emit (node:events:518:28)
[2025-02-07T09:25:46.101Z]     at process.<anonymous> (/home/jenkins/.cache/Cypress/14.0.2/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
[2025-02-07T09:25:46.101Z]     at process.emit (node:events:518:28)
[2025-02-07T09:25:46.101Z]     at emit (node:internal/child_process:951:14)
[2025-02-07T09:25:46.101Z]     at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
[2025-02-07T09:25:46.101Z] error Command failed with exit code 1.
[2025-02-07T09:25:46.101Z] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[2025-02-07T09:25:46.101Z] 

Our Cypress config:

e2e: {
    // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
    setupNodeEvents(on, _config) {
      on('after:spec', (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
        if (results?.video) {
          // Do we have failures for any retry attempts?
          const failures = results.tests.some(test => test.attempts.some(attempt => attempt.state === 'failed'));
          if (!failures) {
            // delete the video if the spec passed and no tests retried
            // eslint-disable-next-line security/detect-non-literal-fs-filename
            fs.unlinkSync(results.video);
          }
        }
      });
      on('task', {
        log: message => {
          // eslint-disable-next-line no-console
          console.log(message);
          return null;
        },
      });
    },

I noticed #28643 fixed a similar issue, and it mentions this scenario specifically as a known scenario:

To handle the known scenario where ffmpeg did not receive enough frames, the error message has been updated to provide context to the Cypress issue.

What is the fix for this known issue, if any? Thank you!

Desired behavior

Give more guidance on how to resolve the issue / the root cause, if it is a known issue.

Test code to reproduce

See the description above

Cypress Version

14.0.2

Node version

20.18.1

Operating System

Jenkins

Debug Logs

Other

I raised this previously with Cypress Cloud Support the first time it happened (we have an enterprise licence at my company) but didn't get very far without providing debug logs - it's intermittent, and we don't want to run our tests with debug logs on all the time.
I'm hoping raising an issue here will make its way back to the engineering implementation team who might be able to give me some more info! Thanks!

@ahayes91
Copy link
Author

ahayes91 commented Feb 7, 2025

Worth putting the fs.unlink statement in a try/catch to see if that resolves the failures in our tests, so I will try that in the meantime. Something like:

      on('after:spec', (_spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
        if (results?.video) {
          // Do we have failures for any retry attempts?
          const failures = results.tests.some(test => test.attempts.some(attempt => attempt.state === 'failed'));
          if (!failures) {
            // delete the video if the spec passed and no tests retried
            try {
              // eslint-disable-next-line security/detect-non-literal-fs-filename
              fs.unlinkSync(results.video);
            } catch (error) {
              // Sometimes we get an error if the test is too short for ffmpeg in Cypress to create a video: https://github.com/cypress-io/cypress/issues/31046
              // eslint-disable-next-line no-console
              console.error('Error deleting video', error);
            }
          }
        }
      });

@jennifer-shehane
Copy link
Member

@ahayes91 Yah, I feel like it's some strange combination of low frames being captured with this logic to delete the video, it doesn't make sense just reading the code though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants