Skip to content

fix: truncate docuhash return value in order to avoid ERRNAMETOOLONG error #4899

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

Merged
merged 6 commits into from
Jun 15, 2021

Conversation

tsirlucas
Copy link
Contributor

@tsirlucas tsirlucas commented Jun 3, 2021

closes #2628

Added a fix based on this. I did a local search and seems like everywhere that is using the docuHash function, its related to a file path so I thought about just adding the code there. If you think its a better idea to add it to a different function and use this function instead of docuHash in the problematic places, just ping me.

Motivation

#2628 (comment)

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Did some local testing with deep file paths and added unit test cases for the docuHash function. Also, added a page for testing deep file paths to the website: http://localhost:3000/deep-file-path-test/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/test-file

@tsirlucas tsirlucas requested review from lex111 and slorber as code owners June 3, 2021 16:59
@facebook-github-bot
Copy link
Contributor

Hi @tsirlucas!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@netlify
Copy link

netlify bot commented Jun 3, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: 3fda0fc

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/60c160ef77ccd60008271823

😎 Browse the preview: https://deploy-preview-4899--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Jun 3, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 59
🟢 Accessibility 97
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4899--docusaurus-2.netlify.app/

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 3, 2021
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@tsirlucas
Copy link
Contributor Author

Got this e2e test error for some reason and updated my branch with master to check if it was the problem. Can you guys point me to a direction on why that was breaking?

@netlify
Copy link

netlify bot commented Jun 9, 2021

✔️ [V1]

🔨 Explore the source changes: 6bf1054

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-1/deploys/60c0d4c46c41e10007014de7

😎 Browse the preview: https://deploy-preview-4899--docusaurus-1.netlify.app

@slorber
Copy link
Collaborator

slorber commented Jun 9, 2021

Got this e2e test error for some reason and updated my branch with master to check if it was the problem. Can you guys point me to a direction on why that was breaking?

Not sure why exactly but we have some random e2e failures sometimes, not a big deal.


@tsirlucas unfortunately your test file does not seem to work on Windows and makes the CI fail, not sure how to fix this, as it seems windows complain about a too-long folder hierarchy on a git checkout

Also, can you move all this code to a dedicated file. Ideally, if this code was stolen from another project, I'd rather link to the original source code (more convenient than using git history), try to isolate the code in a dedicated file and keep it like the original + also copy the tests. Maybe we could have docuHash.ts + pathUtils.ts?

@tsirlucas
Copy link
Contributor Author

tsirlucas commented Jun 10, 2021

@slorber Did the changes you asked for and added a possible fix for the windows problem. Unfortunately I couldnt test it locally because act does not support windows machines, so lets see how it goes.

Also, I didnt add the test/logics for the Preserves trailing slash test case once in the end the code were already appending the filename hash to the end of the string so that wouldnt matter in this use case.

@slorber
Copy link
Collaborator

slorber commented Jun 15, 2021

thanks, LGTM 👍

@slorber slorber merged commit 34411e1 into facebook:master Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERRNAMETOOLONG - Long file names cause issues
3 participants