feat(deploy): CDN bundle sync script and self-hosting docs - #23
Merged
Conversation
Self-hosting environments need a complete, coherent copy of the deployed bundles, and the standard RUM bundle references hash-named chunk files that are error-prone to collect by hand. The script downloads every entry bundle by name and recovers the chunk names from the chunk table webpack embeds in each entry bundle, over plain HTTPS with no credentials, and fails loudly when any file is missing. The bucket layout and the entry filenames move into deploymentUtils.js so the upload and download sides share one definition.
The README pointed at a placeholder static host without saying where released bundles actually live, and still claimed the package had never been verified on a real browser engine. Document the CDN layout and the sync-bundles workflow for self-hosting, and record the real-browser verification outcome: IE 9, 10 and 11 pass every check in the verification page, and IE 6 and IE 8 degrade to a silent no-op.
Three ways the script could hand over something incomplete without saying so: A thrown fetch — a refused connection or a DNS failure, which is the expected shape of trouble for the networks this script exists to serve — escaped the per-file handling, so the run stopped at the first one and the operator got a stack trace instead of the list of what was missing and the warning not to deploy it. Every file is attempted now and all failures are reported together. An interrupted run left a half-written directory that looks exactly like a finished one: an entry bundle without its chunks is unremarkable on disk. Files now land in a directory named for being unfinished and are moved into place only once every one of them is there. An existing output directory is refused rather than merged into, which would have mixed in the chunks of an older version. A chunk whose name webpack had to quote did not match the pattern that reads the chunk table, so it would have been missing from the output without ever being attempted, and so without ever being reported. Both shapes match now, and the count of names read is checked against the count in the table.
The sync script only reads what the release publishes, so it had no business restructuring how the release works to get there. Sharing one definition of the bucket layout would keep the two from drifting, but it bought that by editing production release tooling from a read-only tool, and the layout it needs is three constants. deploy-oss.js and lib/deploymentUtils.js go back to what they were. The script now depends on nothing from the release path and carries its own copy of the host, the directories and the entry filenames.
A body that stops arriving mid-download, or a disk that fills while it is being written, escaped the per-file handling: only the request itself was covered. The run ended on the first one with a stack trace, the remaining files were never attempted, and the operator never saw the list of what was missing or the warning not to deploy it - the same outcome the request handling was added to prevent. Reading and writing the body are inside the same net now. An output directory given with a trailing slash put the staging directory inside it, where the rename cannot land. Every file downloaded successfully and was then stranded in a hidden directory, and since the output directory now existed, the guard refused every re-run. The path is resolved before the staging name is derived from it. A bundle that plainly loads chunks but whose chunk table does not match the pattern now fails loudly. It used to be indistinguishable from a bundle with no chunks at all, so a webpack or terser change to the emitted runtime would have quietly produced a directory missing the very files that are hardest to notice missing. Chunk names decide where this writes and are read out of a downloaded file, so anything resolving outside the output directory is refused.
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.
Stacked on #22 (the rum-legacy README this touches lands there); GitHub will retarget this PR to
mainautomatically once #22 merges.What
scripts/deploy/sync-bundles.js: downloads the deployed bundles from the CDN into a local directory, for serving them from another origin. Entry bundles are fetched by name; the hash-named chunk files of the standard RUM bundle are recovered from the chunk table webpack embeds in the entry bundle, so a synced directory is always complete and coherent. No credentials needed; any missing file fails the run loudly.lib/deploymentUtils.js, shared by the upload (deploy-oss.js) and download sides so they cannot drift apart.packages/rum-legacy/README.md: documents where released bundles live (CDN major-version directory), the self-hosting workflow, and updates the verification status — the claim that the package had never run on a real browser engine is no longer true.Verified
Ran the script against the production CDN: all three released entry bundles plus both chunk files downloaded (chunk-table extraction confirmed against the deployed artifact), and the not-yet-released
fc-rum-legacy.jswas reported as HTTP 404 with a non-zero exit — both the success and the failure paths exercised.