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

test: Avoid race conditions with symlinks #13498

Merged
merged 2 commits into from
Aug 28, 2024
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Aug 28, 2024

Noticed here: https://github.com/getsentry/sentry-javascript/actions/runs/10594383971/job/29358133582 that this was sometimes failing. While looking into this, we actually did unnecessary work here - we had two levels of symlinks. Now we simply have a single symlink, and since we have unique dirs now we can skip checking for existing files etc.

@mydea mydea requested review from lforst and Lms24 August 28, 2024 11:21
@mydea mydea self-assigned this Aug 28, 2024
Also, no need to double-symlink stuff, and since we now build into unique dirs, we can skip the check for existing symlinks as well.
Comment on lines +29 to +30
// ignore errors here, probably means the file already exists
// Since we always build into a new directory for each test, we can safely ignore this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we are better off violently crashing, so that we catch this case when it happens...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is that this does happen :D tests fail without this. the alternative is to check if the file already exists before doing this, but a) this is in reality more overhead than try-catching this (because it only happens in a handful of tests where we have multiple HTML files), and b) it is still prone to flake because of possible race conditions. IMHO it is safe to do this, because each dir that it is building for is for a single test, where we never have the case/desire to have the same file being different from each other - they can safely be the same one always.

@mydea mydea merged commit 5c15485 into develop Aug 28, 2024
117 checks passed
@mydea mydea deleted the fn/test-race-conditions branch August 28, 2024 12:36
martinhaintz added a commit to martinhaintz/sentry-javascript that referenced this pull request Aug 28, 2024
* develop:
  ref: Add external contributor to CHANGELOG.md (getsentry#13500)
  test: Avoid race conditions with symlinks (getsentry#13498)
  fix(node): Suppress tracing for transport request execution rather than transport creation (getsentry#13491)
  ci: Ensure cache save happens after install step (getsentry#13497)
  test: Increase timeout for redis-cache test & docker-compose (getsentry#13499)
  Fix config example in README.md for Nuxt (getsentry#13496)
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

Successfully merging this pull request may close these issues.

2 participants