-
Notifications
You must be signed in to change notification settings - Fork 484
Prevent stale developer playground PR previews #8556
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,14 @@ let isConfiguredVersion = version => | |
| let isLoadableVersion = version => | ||
| version->isConfiguredVersion || version->previewVersionRoot->Option.isSome | ||
|
|
||
| // A PR preview URL is reused after every push, while the CDN caches its assets. | ||
| let previewCacheBust = Date.now()->Float.toString | ||
|
|
||
| let versionAssetUrl = (version, path) => { | ||
| let url = `${versionRoot(version)}/${path}` | ||
| version->isPreviewVersion ? `${url}?cacheBust=${previewCacheBust}` : url | ||
| } | ||
|
Comment on lines
+177
to
+180
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Add an automated test covering this URL-generation behavior: a AGENTS.md reference: AGENTS.md:L169-L174 Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The developer playground does not currently have an automated test harness. Adding one would require introducing and wiring up new test infrastructure, which feels outside the scope of this targeted cache fix. |
||
|
|
||
| let selectableCompilerVersions = activeVersion => | ||
| if activeVersion->isConfiguredVersion || !(activeVersion->previewVersionRoot->Option.isSome) { | ||
| availableCompilerVersions | ||
|
|
@@ -362,16 +370,20 @@ let loadRuntimeLibraries = async version => { | |
| switch activeLibraryVersion.contents { | ||
| | Some(activeVersion) if activeVersion === selectedVersion => () | ||
| | _ => | ||
| let root = versionRoot(selectedVersion) | ||
| let _ = await loadScript(`${root}/compiler-builtins/cmij.js`, ~cache=false) | ||
| let _ = await loadScript( | ||
| versionAssetUrl(selectedVersion, "compiler-builtins/cmij.js"), | ||
| ~cache=false, | ||
| ) | ||
|
|
||
| let libraries = try { | ||
| let _ = await loadScript(`${root}/@rescript/react/cmij.js`, ~cache=false) | ||
| let _ = await loadScript( | ||
| versionAssetUrl(selectedVersion, "@rescript/react/cmij.js"), | ||
| ~cache=false, | ||
| ) | ||
| ["compiler-builtins", "@rescript/react"] | ||
| } catch { | ||
| | _ => ["compiler-builtins"] | ||
| } | ||
|
|
||
| loadedLibrariesByVersion->Map.set(selectedVersion, libraries) | ||
| activeLibraryVersion := Some(selectedVersion) | ||
| } | ||
|
|
@@ -389,8 +401,7 @@ let ensureCompilerApi = async version => { | |
| await loadRuntimeLibraries(selectedVersion) | ||
| compilerApis->getMapValueOrThrow(selectedVersion, "Compiler API was not cached") | ||
| } else { | ||
| let root = versionRoot(selectedVersion) | ||
| await loadScript(`${root}/compiler.js`) | ||
| await loadScript(versionAssetUrl(selectedVersion, "compiler.js")) | ||
| let api = switch Api.global { | ||
| | Some(api) if hasFunction(api, "make") => api | ||
| | _ => JsError.throwWithMessage("rescript_compiler global was not registered by compiler.js") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.