Repository navigation
Register main script handlers before the tag is parsed - #1773
Open
UmmmAGoodName wants to merge 1 commit into
Open
UmmmAGoodName wants to merge 1 commit into
UmmmAGoodName wants to merge 1 commit into
Conversation
The bootstrap that discovers a path prefix (Kestrel PathBase) attached its onerror handler at the end of <body>, while the main bundle is a deferred <script> injected at the end of <head>. Firefox dispatches the error event for a failed deferred script as soon as the fetch fails, so with a fast 404 from the proxy the handler was attached too late and the page stayed white. Move the bootstrap into <head> ahead of the injected tag and register capturing load/error listeners on document up front. Default the base globals to "/" so a non-match degrades to root behaviour, and hold retry scripts until the body is parsed because the bundle mounts on #app synchronously. Fixes JustArchiNET#1635
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1635
Cause
index.htmlattachedmainScript.onerrorat the end of<body>, but the main bundle is a deferred<script>injected at the end of<head>. The browser starts fetching it immediately, and Firefox dispatcheserrorfor a failed deferred script as soon as the fetch fails. With a reverse proxy answering the unprefixed/scripts/main...request with a fast 404, the error arrived before the handler existed and the prefix discovery never ran.Fix
<head>ahead of the injected tag, with capturingload/errorlisteners ondocumentregistered before the tag is parsed. They act once on the parser-inserted main script and detach themselves. (document, notwindow: elementloadevents never reachwindow, even in the capture phase.)/up front, so a future mismatch degrades to root behaviour instead of leaving__BASE_URL__undefined.#appsynchronously and the error can now fire mid-parse.__ASF_UI_LOADED__check unchanged.Verification
Deterministic reproduction: a small node server serves the build under
/asf/, answers everything else with a fast 404, and injects a parser-blocking<script>at the start of<body>that it delays by 1.5 s. This holds the parser before the old bootstrap while the 404 for the root bundle has already arrived./asf/scripts/Also verified: deep nested route (
/asf/bots/x/config) walks up to/asf/, root deployment without prefix sets the defaults, dev server boots.