Open
Conversation
…nflict Multiple concurrent requests (e.g. the loading-page waitUntil + the next polling request) can both call mountR2Storage before the first one finishes. Each call to sandbox.mountBucket() appends credentials to the s3fs passwd file, so concurrent calls produce duplicate entries and s3fs refuses to mount with: "there are multiple entries for the same bucket(default) in the passwd file." This adds a module-level in-flight promise that coalesces concurrent mount calls: only the first caller actually attempts the mount, while subsequent callers await the same promise. The lock is released in a finally block so retries are possible after failures. https://claude.ai/code/session_01E5t9gPHDGGrTUWeagkDjVo
fix: prevent concurrent R2 mount attempts causing s3fs passwd file co…
Two issues caused the "multiple entries for the same bucket(default) in the passwd file" s3fs error: 1. sandbox.mountBucket() appends credentials to the s3fs passwd file on every call. Because the container persists across Worker invocations (keepAlive / sleepAfter), stale entries from previous mounts accumulate and s3fs refuses to mount. Fix: clear /etc/passwd-s3fs and ~/.passwd-s3fs before each mount attempt. 2. Concurrent requests (e.g. the loading-page waitUntil + the next polling request) can both call mountR2Storage before the first one finishes, producing parallel mountBucket() calls that each append entries. Fix: coalesce concurrent callers behind a single in-flight promise. https://claude.ai/code/session_01E5t9gPHDGGrTUWeagkDjVo
…rDsd fix: prevent duplicate s3fs passwd entries on R2 mount
…uplication sandbox.mountBucket() manages the s3fs passwd file from the orchestration layer outside the container and appends a new credential entry on every call. Because the container persists across Worker invocations the entries accumulate and s3fs refuses to mount with "multiple entries for the same bucket(default) in the passwd file." In-container cleanup (rm, sort -u) cannot reach the orchestration-layer file. Replace mountBucket() with direct s3fs mounting inside the container, following the pattern from the Cloudflare Containers FUSE-mount docs: 1. Write credentials to /etc/passwd-s3fs via startProcess (overwrite, not append — always exactly one entry) 2. Run s3fs directly inside the container 3. Verify the mount succeeded Credentials are passed via process env vars (R2_KEY, R2_SECRET) to avoid embedding secrets in the command string. The in-flight promise lock is retained to coalesce concurrent callers within the same Worker isolate. https://claude.ai/code/session_01E5t9gPHDGGrTUWeagkDjVo
01e14d3 to
8f324b3
Compare
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.
No description provided.