-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(loader): provide js sdk assets from 4.x #3415
Conversation
Pinging @dlouzan for visibility |
I have no idea on why the unit test fails at a very random moment. Will revisit later. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3415 +/- ##
=======================================
Coverage 99.01% 99.01%
=======================================
Files 3 3
Lines 203 203
=======================================
Hits 201 201
Misses 2 2 ☔ View full report in Codecov by Sentry. |
install/setup-js-sdk-assets.sh
Outdated
fi | ||
|
||
echo "Downloading JS SDK v${version} for ${variant}.min.js..." | ||
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx curl --retry 3 -sLo /var/www/js-sdk/${version}/${variant}.min.js "https://browser.sentry-cdn.com/${version}/${variant}.min.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also ended up using curl in our adapted script; busybox's wget is crippled and weird, and doesn't play nice with corporate proxies.
latest_js_v7=$(echo "$loader_registry" | $jq -r '.versions | reverse | map(select(.|any(.; startswith("7.")))) | .[0]') | ||
latest_js_v8=$(echo "$loader_registry" | $jq -r '.versions | reverse | map(select(.|any(.; startswith("8.")))) | .[0]') | ||
|
||
echo "Found JS SDKs v${latest_js_v7} and v${latest_js_v8}, downloading from upstream.." | ||
echo "Found JS SDKs: v${latest_js_v4}, v${latest_js_v5}, v${latest_js_v6}, v${latest_js_v7}, v${latest_js_v8}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what decides which versions are available, and how this script will be properly kept up to date with newer releases, as this does not do auto-discovery based on metadata 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one JSON file that's always populated on Docker build time on the sentry
container. (In which tested here https://github.com/getsentry/sentry/blob/fda38c5d70c4ef8c7340cfd5978d97ccf25b6674/self-hosted/Dockerfile#L85)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can find the current versions at the time of installation from https://github.com/getsentry/sentry-release-registry/tree/master/packages/npm/%40sentry/browser
Co-authored-by: Burak Yigit Kaya <[email protected]>
install/setup-js-sdk-assets.sh
Outdated
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx mkdir -p /var/www/js-sdk/${version} | ||
for variant in "tracing" "tracing.replay" "replay" "tracing.replay.feedback" "feedback"; do | ||
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx wget -q -O /var/www/js-sdk/${version}/bundle.${variant}.min.js "https://browser.sentry-cdn.com/${version}/bundle.${variant}.min.js" | ||
for variant in "bundle" "bundle.tracing" "bundle.tracing.replay" "bundle.replay" "bundle.tracing.replay.feedback" "bundle.feedback"; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to pull this list out of the for loops for better visibility and modification in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Tests are green too
install/setup-js-sdk-assets.sh
Outdated
status_code=$($dcr --no-deps --rm nginx curl --retry 3 --silent -I "https://browser.sentry-cdn.com/${version}/${variant}.min.js" 2>/dev/null | head -n 1 | cut -d$' ' -f2) | ||
if [[ "$status_code" != "200" ]]; then | ||
echo "Skipping download of JS SDK v${version} for ${variant}.min.js, because the status code was ${status_code} (non 200)" | ||
continue | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not use the -f/--fail
flag yet (https://superuser.com/a/657174)
I think it was added in a newer version of curl
so not sure if it would be available here. Would be great if it is though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nginx image has the curl version of 8.1.x. Should be fine.
The unit test is so flaky. I don't know why. |
if [[ "$status_code" != "200" ]]; then | ||
echo "Skipping download of JS SDK v${version} for ${variant}.min.js, because the status code was ${status_code} (non 200)" | ||
continue | ||
fi | ||
|
||
echo "Downloading JS SDK v${version} for ${variant}.min.js..." | ||
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx curl --retry 3 -sLo /var/www/js-sdk/${version}/${variant}.min.js "https://browser.sentry-cdn.com/${version}/${variant}.min.js" | ||
$dcr --no-deps --rm -v "sentry-nginx-www:/var/www" nginx curl --retry 10 -sLo /var/www/js-sdk/${version}/${variant}.min.js "https://browser.sentry-cdn.com/${version}/${variant}.min.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These retries are sad :D
Hopefully fixes getsentry/sentry#22715 (comment)
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.