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

[FIX] ENAMETOOLONG: name too long, ... errors due to too long name of generated temp directory #174

Open
ptabor opened this issue Sep 1, 2023 · 4 comments
Assignees

Comments

@ptabor
Copy link

ptabor commented Sep 1, 2023

In case of running jest-html-reporter in the deeply nested trees it fails with:

    Error: An error occurred while adding the reporter at path "/private/var/tmp/_bazel_ptabor/7822fa32d222a4d7f0cf5a703ea68dac/sandbox/darwin-sandbox/2035/execroot/sfc_snapps/bazel-out/darwin_arm64-fastbuild/bin/src/[redacted]/.aspect_rules_js/jest-html-reporters@3.1.4/node_modules/jest-html-reporters/index.js".
    
    ENAMETOOLONG: name too long, unlink '/var/folders/p3/x51cvt2j2dj9cb7rrq2pzg_80000gn/T/L3ByaXZhdGUvdmFyL3RtcC9fYmF6ZWxfcHRhYm9yLzc4MjJmYTMyZDIyMmE0ZDdmMGNmNWE3MDNlYTY4ZGFjL3NhbmRib3gvZGFyd2luLXNhbmRib3gvMjAzNS9leGVjcm9vdC9zZmNfc25hcHBzL2JhemVsLW91dC9kYXJ3aW5fYXJtNjQtZmFzdGJ1aWxkL2Jpbi9zcmMvW3JlZGFjdGVkLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLnJlZGFjdGVkXQo/jest-html-reporters-temp']

This problem is especially likely to happen when using on Bazel (that uses long paths).

Here is a patch that fixes the problem - by generating SHA checksum of the base folder instead of encoding the entire path in its name:

https://github.com/Hargne/jest-html-reporter/compare/master...ptabor:20230901-checsum-instead-of-base64?expand=1

@sfc-gh-ptabor
Copy link

@Hargne Could you, please, take a look and create PR from the diff (I cannot push a branch here).

@Hargne Hargne self-assigned this Nov 9, 2023
@Hargne
Copy link
Owner

Hargne commented Jun 2, 2024

Hi and sorry for the late response 😅

Could you provided with an example of where this would be implemented in this code base? I am struggling to replicate the issue on my end.

Thanks a bunch!

@ptabor
Copy link
Author

ptabor commented Jun 2, 2024

The whole patch to apply in your code is here:

https://github.com/Hargne/jest-html-reporter/compare/master...ptabor:20230901-checsum-instead-of-base64?expand=1#diff-9c4c6148b34d502eafc592468318c68e6b3383698e94c869700517af02b885a2

It's just using sha of the directory name instead of the full dictionary name.

To reproduce the issue try putting your jest-project in a directory that have very long name:

mkdir -p private/var/tmp/_bazel_ptabor/7822fa32d222a4d7f0cf5a703ea68dac/sandbox/darwin-sandbox/2035/execroot/sfc_snapps/bazel-out/darwin_arm64-fastbuild/bin/src/abcdefghijklmn123456789/

In the prior code, it would lead to an attempt of creation of working dir that has name exceeding 256 chars, like:
L3ByaXZhdGUvdmFyL3RtcC9fYmF6ZWxfcHRhYm9yLzc4MjJmYTMyZDIyMmE0ZDdmMGNmNWE3MDNlYTY4ZGFjL3NhbmRib3gvZGFyd2luLXNhbmRib3gvMjAzNS9leGVjcm9vdC9zZmNfc25hcHBzL2JhemVsLW91dC9kYXJ3aW5fYXJtNjQtZmFzdGJ1aWxkL2Jpbi9zcmMvW3JlZGFjdGVkLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLnJlZGFjdGVkXQo

@Hargne
Copy link
Owner

Hargne commented Jun 2, 2024

Ahaa!
You are referring a different library - https://github.com/Hazyzh/jest-html-reporters (notice the extra "s" at the end)

No wonder I was so confused above the linked code 😅

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

No branches or pull requests

3 participants