anomalyco/sst · error

bucket %v upload failed: %w

Error message

bucket %v upload failed: %w

What it means

This error wraps a failure from WorkerAssets.uploadAssets when one of the 3 concurrent workers fails to upload a bucket of asset file hashes during the Cloudflare Workers assets upload. The bucket (a []string of content hashes) is embedded in the message and the underlying cause is wrapped with %w. The error surfaces from handleUpload after wg.Wait when the errChan is drained.

Source

Thrown at pkg/server/resource/cloudflare-worker-assets.go:125

	}

	// Create channels for work distribution and error collection
	bucketsChan := make(chan []string)
	errChan := make(chan error, len(initResponse.Buckets))
	jwtChan := make(chan string, len(initResponse.Buckets))
	var wg sync.WaitGroup

	// Start worker pool (3 workers)
	numWorkers := 3
	for i := 0; i < numWorkers; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()
			// Each worker processes buckets from the channel
			for hashes := range bucketsChan {
				jwt, err := r.uploadAssets(manifest, directory, accountId, apiToken, hashes, initResponse.Jwt)
				if err != nil {
					errChan <- fmt.Errorf("bucket %v upload failed: %w", hashes, err)
					return
				}

				if jwt != "" {
					jwtChan <- jwt
				}
			}
		}()
	}

	// Send buckets to the channel
	go func() {
		for _, bucketHashes := range initResponse.Buckets {
			bucketsChan <- bucketHashes
		}
		close(bucketsChan)
	}()

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Rerun the deploy — the error often stems from transient HTTP failures during asset upload
  2. Check the wrapped cause (%w) in the error chain for the actual HTTP status or reason
  3. Regenerate the upload session so the JWT is fresh, and avoid modifying files in the assets directory during deploy
  4. Verify the API token has Workers Scripts Edit / assets upload permissions for the account
  5. Reduce asset count or retry with fewer concurrent buckets if hitting rate limits
Defensive patterns

Strategy: try-catch

Validate before calling

// before deploy: ensure files are stable and token is valid
hashBefore := hashDirectory(directory)
time.Sleep(1 * time.Second)
if hashBefore != hashDirectory(directory) {
    return errors.New("assets directory changed during deploy; retry when stable")
}

Try / catch

err := workerAssets.Create(input, &out)
if err != nil {
    if strings.Contains(err.Error(), "bucket ") { // wrapped bucket upload failure
        // retry the whole upload once; transient HTTP failures are common
        err = workerAssets.Create(input, &out)
    }
    if err != nil {
        return err
    }
}

Prevention

When it happens

Trigger: uploadAssets fails for a bucket during Create/Update of a Worker with assets — e.g. the upload session JWT expired, the PUT/POST of asset files to the Cloudflare upload endpoint returned non-2xx, network interruption mid-upload, an API token lacking Workers assets permission, or a file in the directory was modified/deleted after the manifest was computed.

Common situations: Large asset directories split into many buckets where one slow/transient HTTP failure aborts the whole deploy; expired or revoked Cloudflare API token mid-deploy; file watching (dev mode) changing files between manifest creation and upload; Cloudflare API rate limiting from very large asset sets.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/7903b121dc966331. Report an issue: GitHub.