Cypress: Screenshot file name too long warning when Bytes exceeded

Created on 28 Aug 2018  Β·  16Comments  Β·  Source: cypress-io/cypress

Current behavior:

Currently I use BDD to document acceptance test cases, each test scenario is well detailed, Cypress uses the description of "it" to create the screenshot file name, but when "it" exceeds 255 characters it is not possible to create the screenshot file.

  6) As a quality manager, i would like to query the occurence history to find information about them GIVEN that im onthe search sreen, WHEN i fill in the ocurrence date fields, check the only delayed ones box and click on the filter button, THEN i see the filtered results:
     Error: ENAMETOOLONG: name too long, open '/home/node/cypress/screenshots/tools/us6.spec.js/As a quality manager iwould like to query the occurence history to find information about them -- GIVEN that im on the search sreen WHEN i fill in the ocurrence date fields check the only delayed ones box and click on the filter button THEN i see the filteredresults (failed).png'

Desired behavior:

  1. I hope Cypress allows me to change the name of the destination file from the screenshot before it writes it.
  2. Or, I hope Cypress will worry about the size of the file before it writes it and limits it to 255 characters.

Steps to reproduce:

  1. Create a test case with "it" description too long, bigger then 255 caracteres.
  2. Make a test case broken.
  3. Run tests.
  4. Look the verbose log, the screenshot not was created.

Versions

Cypress: 3.0.3
Browser: Chrome 67

┆Issue is synchronized with this Jira Bug by Unito

first-timers-only internal-priority bug

Most helpful comment

+1

All 16 comments

Thanks for reporting this. We definitely need to catch that error and truncate the file name as needed. I'm hesitant to always truncate at an arbitrary character length since that's going to be OS-dependent and there may be an operating system with an even lower limit.

Speaking of which, on what operating system are you encountering this?

Unfortunately, there's no way to change the screenshot path before it's written to disk. We'd need to add a new plugin event that enables that.

Thank's for response @chrisbreiding , we are running on Ubuntu 16, Ubuntu 18 and Docker image cypress/browsers:chrome67

+1

+1

I also got this issue on our internal tests. πŸ™ˆ

Error: ENAMETOOLONG: name too long, open '/root/cypress-dashboard/cypress/screenshots/project_spec.coffee/Project -- route to project -- permission to view private project -- grace period banner -- billing feature flag ON -- as owner or admin -- not over test recordings -- displays banner with link to billing (failed).png'

I got the same situation with 3.2.0 version. @lilaconlee Can you please look here?

cypress:server:socket automation:request take:screenshot { 
  titles: [ 
    'WMED: [STORY] ВСстовыС сцСнарии для CI', 
    'Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΈ:', 
    'Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2: Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ обращСния, созданиС мСдзаписи, привязка обращСния ΠΊ мСдзаписи', 
    '- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2' 
  ], testId: 'r7', simple: true, testFailure: true, capture: 'runner', clip: { x: 0, y: 0, width: 1050, height: 932 }, viewport: { width: 1050, height: 932 }, scaled: true, blackout: [], startTime: '2019-05-08T09:03:20.993Z' 
}
cypress:server:screenshot (s1) capturing screenshot { 
  titles: [ 
    'WMED: [STORY] ВСстовыС сцСнарии для CI', 
    'Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΈ:', 
    'Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2: Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ обращСния, созданиС мСдзаписи, привязка обращСния ΠΊ мСдзаписи', 
    '- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2' 
  ], testId: 'r7', simple: true, testFailure: true, capture: 'runner', clip: { x: 0, y: 0, width: 1050, height: 932 }, viewport: { width: 1050, height: 932 }, scaled: true, blackout: [], startTime: '2019-05-08T09:03:20.993Z', specName: 'WMED_UAT_Scenarios_For_CI_spec.js' }
...
cypress:server:screenshot (s1) save /jenkins-slave/workspace/test-wmed/qa/cypress/wmed_ci/cypress/screenshots/WMED_UAT_Scenarios_For_CI_spec.js/WMED [STORY] ВСстовыС сцСнарии для CI -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΈ -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ обращСния, созданиС мСдзаписи, привязка обращСния ΠΊ мСдзаписи -- - Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 (failed).png
cypress:server:screenshot (s1) clearing 0 cached multipart images
...
cypress:server:project onMocha fail
cypress:server:reporter got mocha event 'fail' with args: [ 
  { 
    id: 'r7', 
    title: '- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2', 
    err: { 
      message: 'ENAMETOOLONG: name too long, open \'/jenkins-slave/workspace/test-wmed/qa/cypress/wmed_ci/cypress/screenshots/WMED_UAT_Scenarios_For_CI_spec.js/WMED [STORY] ВСстовыС сцСнарии для CI -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΈ -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ обращСния, созданиС мСдзаписи, привязка обращСния ΠΊ мСдзаписи -- - Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 (failed).png\'', 
      name: 'Error', 
      stack: 'Error: ENAMETOOLONG: name too long, open \'/jenkins-slave/workspace/test-wmed/qa/cypress/wmed_ci/cypress/screenshots/WMED_UAT_Scenarios_For_CI_spec.js/WMED [STORY] ВСстовыС сцСнарии для CI -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΈ -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ обращСния, созданиС мСдзаписи, привязка обращСния ΠΊ мСдзаписи -- - Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 (failed).png\'\n\n' }, 
      state: 'failed', 
      body: 'function (

@AlDemion Thanks so much for providing the logs.

I tested nesting some long suite titles, which passed for me.

I then tried pasting in the exact titles of your test suites - this also passed for me.

I changed the filename, so that the path would be really long - this also passed for me!

So, I haven't been able to recreate completely with my guesswork.

Can you post the full body of the error message in the DEBUG log? When you pasted, you cut it off at state: 'failed', body: function ( - I need the info printed here to see the stack of where this is being thrown.

Hello! I've come across with the issue that even after Cypress truncate extra letters from file name I still get ENAMETOOLONG error in CI.

I figured out that the cause of that is using Cyrillic letters in Cypress tests.

  • My filesystem has file name limit in 255 bytes (not characters).
  • One Cyrillic letter takes 2 bytes instead of 1 byte.
  • When Cypress checks if the file name is not too long it seems to be checking characters but not bytes.

So it happens that file name with Cyrillic letter pass the Cypress validation but not file system validation.

@AlDemion maybe you have the same issue. I've checked how many characters vs bytes in your example in apfs:

echo "WMED [STORY] ВСстовыС сцСнарии для CI -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΈ -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ обращСния, созданиС мСдзаписи, привязка обращСния ΠΊ мСдзаписи -- - Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 (failed).png" | wc -m

Logs 164

echo "WMED [STORY] ВСстовыС сцСнарии для CI -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΈ -- Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ обращСния, созданиС мСдзаписи, привязка обращСния ΠΊ мСдзаписи -- - Π‘Ρ†Π΅Π½Π°Ρ€ΠΈΠΉ 2 (failed).png" | wc -c

Logs 268

And it seems that your filename might actually exceed your filesystem limits

@kuznetsovaOk Thanks for the explanation @kuznetsovaOk, this is amazing, thank you!

The max filename length is dependent on the file system that Cypress would be running in and all of them are listed here: https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits

But yeah, I think the key takeaway here is that chars !== bytes. Reopening to address bytes issues.

When is this issue expected to be resolved? This is a breaking issue for build pipelines so should be seen as a high priority. Not sure why in over a year it hasn't yet been fixed!

Yeah @kuznetsovaOk You got the point. It seems that all the problems in the file system limits. But I can't change the filesystem, so one hope is that the issue will be fixed by truncating the filename or by using a randomly generated string for the screenshot name.

The patch should be simple enough, if someone having this issue wants to open a PR. We most likely just need to use Buffer.byteLength instead of String.prototype.length here:

https://github.com/cypress-io/cypress/blob/98063aec64fe42df6680f227a2aaf5692b73af88/packages/server/lib/screenshots.coffee#L329

We're running into this in the cypress/included:4.2.0 container with no Cyrillic characters. The breakdown from the ENAMETOOLONG error message is like this:

<96 character path to spec file>/<131 character spec title> -- before all hook (failed).png

A total of 260 characters. Is there any workaround?

The original issue opened by @rafaelcaviquioli was fixed, by this PR: #2635

The issue @AlDemion and @kuznetsovaOk are running in to seems to be caused by the difference between String.length and Buffer.byteLength as described here: https://github.com/cypress-io/cypress/issues/2403#issuecomment-551872521

I've opened a PR that truncates filenames to a maximum of bytes on all operating systems.


@jbergknoff-rival you can try building from my PR and see if it fixes your issue, or if you want, you can share the filenames that are causing problems and I can try to see. Any Unicode character could cause this problem.

If you don't have any Unicode in your filenames, could you also share debug logs from the time that issue occurs?

The code for this is done in cypress-io/cypress#8175, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

Released in 5.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.0.0, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

egucciar picture egucciar  Β·  3Comments

tahayk picture tahayk  Β·  3Comments

weskor picture weskor  Β·  3Comments

brian-mann picture brian-mann  Β·  3Comments

zbigniewkalinowski picture zbigniewkalinowski  Β·  3Comments