Skip to content

fix: await pipeTo to prevent upload UUID race condition - #16

Merged
rubenhensen merged 1 commit into
mainfrom
fix/upload-uuid-race-condition
Apr 14, 2026
Merged

fix: await pipeTo to prevent upload UUID race condition#16
rubenhensen merged 1 commit into
mainfrom
fix/upload-uuid-race-condition

Conversation

@rubenhensen

@rubenhensen rubenhensen commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • withTransform called pipeTo fire-and-forget, causing a race condition where getUuid() could be called before initUpload resolved
  • Now returns the pipeTo promise as pipeDone so the caller can await the full pipe chain before reading the UUID

Root cause

The upload stream's start() method calls initUpload (a network request) which sets the UUID. But pipeTo was not awaited, so sealStream could complete and getUuid() could run before start() finished — returning an empty string.

Test plan

  • Encrypt & send a file via the SvelteKit example, verify the UUID is displayed in the success state
  • Encrypt & upload (upload-only mode), verify the UUID and download link are displayed

withTransform was calling pipeTo as fire-and-forget, so getUuid() could
be called before the upload stream's start() (which calls initUpload
and receives the UUID) had resolved.
@rubenhensen
rubenhensen merged commit cdd6d82 into main Apr 14, 2026
1 check passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dobby-coder
dobby-coder Bot deleted the fix/upload-uuid-race-condition branch April 29, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant