Skip to content

fix: write the manifest file before uploading a bundle - #206

Merged
robingenz merged 1 commit into
mainfrom
fix/manifest-write-race
Aug 18, 2026
Merged

fix: write the manifest file before uploading a bundle#206
robingenz merged 1 commit into
mainfrom
fix/manifest-write-race

Conversation

@robingenz

Copy link
Copy Markdown
Member

generateManifestJson called writeFile without awaiting it, so it resolved before capawesome-live-update-manifest.json existed on disk. uploadFiles then immediately re-listed the directory to decide what to upload — the pending write and the readdir are 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 answered 404 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, readdir always finds the entry. zip bundles never touch this path.

apps:liveupdates:bundle had the same race, where it could emit an archive with a missing or truncated manifest.

Changes

  • Await the manifest write before returning from generateManifestJson.
  • Add a regression test asserting the manifest exists on disk once the promise resolves.

Fixes capawesome-team/capacitor-plugins#970

Copilot AI lite review requested due to automatic review settings August 18, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 generateManifestJson to guarantee the file exists before the function resolves.
  • Add a regression test to assert the manifest exists on disk after generateManifestJson completes 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.

@robingenz
robingenz merged commit 631e99b into main Aug 18, 2026
4 checks passed
@robingenz
robingenz deleted the fix/manifest-write-race branch August 18, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: manifest-to-manifest partial update never becomes active on iOS - silent failure, device stuck on previous bundle

2 participants