{"record":{"id":"7903b121dc966331","repo":"anomalyco/sst","slug":"bucket-v-upload-failed-w","errorCode":null,"errorMessage":"bucket %v upload failed: %w","messagePattern":"bucket (.+?) upload failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/server/resource/cloudflare-worker-assets.go","lineNumber":125,"sourceCode":"\t}\n\n\t// Create channels for work distribution and error collection\n\tbucketsChan := make(chan []string)\n\terrChan := make(chan error, len(initResponse.Buckets))\n\tjwtChan := make(chan string, len(initResponse.Buckets))\n\tvar wg sync.WaitGroup\n\n\t// Start worker pool (3 workers)\n\tnumWorkers := 3\n\tfor i := 0; i < numWorkers; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\t// Each worker processes buckets from the channel\n\t\t\tfor hashes := range bucketsChan {\n\t\t\t\tjwt, err := r.uploadAssets(manifest, directory, accountId, apiToken, hashes, initResponse.Jwt)\n\t\t\t\tif err != nil {\n\t\t\t\t\terrChan <- fmt.Errorf(\"bucket %v upload failed: %w\", hashes, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tif jwt != \"\" {\n\t\t\t\t\tjwtChan <- jwt\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t}\n\n\t// Send buckets to the channel\n\tgo func() {\n\t\tfor _, bucketHashes := range initResponse.Buckets {\n\t\t\tbucketsChan <- bucketHashes\n\t\t}\n\t\tclose(bucketsChan)\n\t}()\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/server/resource/cloudflare-worker-assets.go#L107-L143","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rerun the deploy — the error often stems from transient HTTP failures during asset upload","Check the wrapped cause (%w) in the error chain for the actual HTTP status or reason","Regenerate the upload session so the JWT is fresh, and avoid modifying files in the assets directory during deploy","Verify the API token has Workers Scripts Edit / assets upload permissions for the account","Reduce asset count or retry with fewer concurrent buckets if hitting rate limits"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before deploy: ensure files are stable and token is valid\nhashBefore := hashDirectory(directory)\ntime.Sleep(1 * time.Second)\nif hashBefore != hashDirectory(directory) {\n    return errors.New(\"assets directory changed during deploy; retry when stable\")\n}","typeGuard":null,"tryCatchPattern":"err := workerAssets.Create(input, &out)\nif err != nil {\n    if strings.Contains(err.Error(), \"bucket \") { // wrapped bucket upload failure\n        // retry the whole upload once; transient HTTP failures are common\n        err = workerAssets.Create(input, &out)\n    }\n    if err != nil {\n        return err\n    }\n}","preventionTips":["Don't modify or delete files in the assets directory during deploy","Use a fresh, valid API token with Workers assets upload permission","Retry deploys on failure — transient HTTP errors during multi-bucket uploads are common","For very large asset sets, verify you aren't hitting Cloudflare rate limits and consider batching"],"tags":["cloudflare","workers","assets","upload","concurrency"],"backgroundTag":"asset-upload-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}