-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: resolve files outside the project directory to the bundled directory #30067
Merged
+161
−11
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…tory via the directory path difference [run ci]
AtofStryker
changed the title
fix: resolve files outside the project directory to the bundled direc…
fix: resolve files outside the project directory to the bundled directory
Aug 20, 2024
cypress Run #56721
Run Properties:
|
Project |
cypress
|
Branch Review |
fix/8599
|
Run status |
Passed #56721
|
Run duration | 52m 12s |
Commit |
08f539fa27: update common ancestor code
|
Committer | AtofStryker |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
2
|
Pending |
26
|
Skipped |
0
|
Passing |
769
|
View all changes introduced in this branch ↗︎ |
UI Coverage
65.48%
|
|
---|---|
Untested elements |
27
|
Tested elements |
55
|
Accessibility
96.6%
|
|
---|---|
Failed rules |
0 critical
8 serious
3 moderate
0 minor
|
Failed elements |
210
|
ryanthemanuel
approved these changes
Aug 22, 2024
Binary file provided seems to fix the issue on our end. Thanks |
cacieprins
approved these changes
Aug 22, 2024
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additional details
Files that live outside of the user's project directory that are referenced by the project (ex.
../support.js
support file reference insidecypress.config.js
) did not resolve correctly on Windows. This is only noticable on Windows since the absolute path gets appended to the project bundle. In Unix based systems, this goes unnoticed because/Users/foo/project/nested/hash-bundle/Users/foo/project/file.js
is a valid path in Unix, butC:\Users\foo\project\nested\hash-bundleC:\Users\foo\project\file.js
is not a valid path in WindowsTo resolve this issue, we find the common ancestor directory between the project and file, take the path AFTER the common ancestor directory of the file, and append it to the project bundle directory. Effectively
C:\Users\foo\project\nested\hash-bundleC:\Users\foo\project\file.js
becomesC:\Users\foo\project\nested\hash-bundle\file.js
. Collisions here are technically possible, but it seems highly unlikely.I was originally going to use a library called
common-ancestor-path
, but it was fairly difficult to mock thepath
dependencies to get the correct separator when trying to mockwin32
paths inside aposix
context. The library was small enough to modify for our needs that I added in theapp_data
file.Before
After
Steps to test
Tests for the
findCommonAncestor
and thegetBundledFilePath
fixes are unit tested. I contemplated adding a system-test, but because the support file would have to live outside the project directory (or some other spec) and would need to run it on windows specifically, I opted to not add one since the maintenance cost seems to outweigh the benefits. Reevaluating, I think the unit tests here should give us enough coverage for what we expect, but I do not feel great about how much stubbing has to happen to testwin32
libraries onposix
.If you want to test this fix fully end to end, you can clone this fork on windows and test with the
13.13.3
binary to see the failure, then install the binary built on this branch, https://cdn.cypress.io/beta/npm/13.14.0/win32-x64/fix/8599-e6b74fd2fa67f8731a80cda7d12ce23d0d5d9fd0/cypress.tgz, and see the issue is fixed. The file will now be available outputted by webpack in the bundle hash directory.Note: You will not be able to reproduce the issue meaningfully on mac or linux.
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?