fix: write the manifest file before uploading a bundle - #206
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a race condition in Live Update manifest generation where the manifest file write could still be in-flight when the bundle upload logic re-scanned the directory, causing bundles to be uploaded without capawesome-live-update-manifest.json.
Changes:
- Await the manifest file write in
generateManifestJsonto guarantee the file exists before the function resolves. - Add a regression test to assert the manifest exists on disk after
generateManifestJsoncompletes and that the manifest excludes itself from the file list.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/utils/manifest.ts | Awaits the manifest write to eliminate a write-vs-readdir race during bundle upload/archive generation. |
| src/utils/manifest.test.ts | Adds a regression test ensuring the manifest is written before resolve and contains only the expected asset entries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
generateManifestJsoncalledwriteFilewithout awaiting it, so it resolved beforecapawesome-live-update-manifest.jsonexisted on disk.uploadFilesthen immediately re-listed the directory to decide what to upload — the pending write and thereaddirare two independent libuv threadpool tasks, so whether the manifest was included was a coin flip.When the race was lost, every other file was uploaded but the manifest was not. No error was raised, the bundle was marked
ready, and the server permanently answered404 File not found.for?href=capawesome-live-update-manifest.json. Devices could never install the bundle.A reproduction of the exact call sequence (183 files, 200 runs) dropped the manifest 44 times; the reporter measured roughly 1 in 2 on their machine. Only manifest bundles built from a freshly cleaned output folder are affected — if a manifest from a previous run is still present,
readdiralways finds the entry.zipbundles never touch this path.apps:liveupdates:bundlehad the same race, where it could emit an archive with a missing or truncated manifest.Changes
generateManifestJson.Fixes capawesome-team/capacitor-plugins#970