workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

R2-3483 : `R2 put: Unspecified error` on remote binding

Open hexcowboy opened this issue 6 months ago • 17 comments

What versions & operating system are you using?

Wrangler 4.20.5

Please provide a link to a minimal reproduction

No response

Describe the Bug

Letting my local wrangler instance sit idle for a while eventually causes requests to R2 remote bindings to throw. PUTs to R2 specifically throw an error (see error below).

Restarting my wrangler dev fixes this. I'm able to provide more details if needed.

Please provide any relevant error logs

▲ [WARNING] workerd/api/r2-rpc.c++:242: warning: R2 error response does not contain the CF-R2-Error header.; response.statusCode = 400

error [Error: put: Unspecified error (0)]

hexcowboy avatar Jun 24 '25 04:06 hexcowboy

Thanks for reporting this! Would you be able to provide a reproduction repo that demonstrates the issue?

penalosa avatar Jun 30 '25 13:06 penalosa

Hi @penalosa here is a very basic reproduction: https://github.com/hexcowboy/cf-workers-remote-binding-bug

Image

➜ curl -X POST http://localhost:3009/upload/test-3
Internal Server Error%

To reproduce, let the dev server sit idle. I'm not sure exactly how long this takes but after 2 hours of idle I reproduced it in the screenshot above.

hexcowboy avatar Jul 01 '25 02:07 hexcowboy

Also seeing this for other R2 operations like head

▲ [WARNING] workerd/api/r2-rpc.c++:122: warning: R2 error response does not contain the CF-R2-Error header.; respons
e.statusCode = 400


✘ [ERROR] [Error: head: Unspecified error (0)]

hexcowboy avatar Jul 02 '25 18:07 hexcowboy

I am experiencing the same error. I'll go back to using an S3 implementation for now.

bastiankistner avatar Jul 06 '25 22:07 bastiankistner

hi @hexcowboy,

thank you so much for the repro 🙏 . I noticed that in your repro you are using the experimental remote mode, and was wondering if you are experiencing the same issue in remote mode proper

CarmenPopoviciu avatar Jul 07 '25 13:07 CarmenPopoviciu

@CarmenPopoviciu After about 1.5h idle with --remote instead of --x-remote-bindings, I'm seeing a different error

Image

➜ curl -X POST http://localhost:3009/upload/test-5
error code: 1031%

hexcowboy avatar Jul 07 '25 16:07 hexcowboy

Usually restart helps, but today I have this error on permanent basis workerd/api/r2-rpc.c++:242: warning: R2 error response does not contain the CF-R2-Error header.; response.statusCode = 503

istarkov avatar Jul 30 '25 13:07 istarkov

hi all, we're checking with the internal team about this error, but in the meantime @istarkov to clarify, are you running with remote bindings or wrangler dev --remote?

lrapoport-cf avatar Sep 08 '25 14:09 lrapoport-cf

we've raised an internal ticket: R2-3483

lrapoport-cf avatar Sep 08 '25 14:09 lrapoport-cf

remote bindings through import adapter from "@sveltejs/adapter-cloudflare";

    adapter: adapter({
      platformProxy: {
        // environment: "staging",
        configPath: "./wrangler.jsonc",
        experimental: {
          remoteBindings: true,
        },
      },
    }),

The issue probably somehow depends on the connection quality. I had issue with my router, it seems like it broke idle connections with > 60s idle timeout. I still see the issue periodically, but not that often like that day.

istarkov avatar Sep 09 '25 18:09 istarkov

Having the same issue.

orkerd/api/r2-rpc.c++:122: warning: R2 error response does not contain the CF-R2-Error header.; response.statusCode = 400

mohsentaleb avatar Sep 11 '25 10:09 mohsentaleb

  1. wrangler.json with below binding:
      "main": "src/main.ts",
      "compatibility_date": "2025-04-17",
      "compatibility_flags": [
        "nodejs_compat"
      ],
      "r2_buckets": [
        {
          "bucket_name": "example-bucket",
          "binding": "example_bucket",
          "experimental_remote": true
        }
      ],
  1. wrangler dev --persist-to ../../.wrangler/state --x-remote-bindings using 4.33.2 on Ubuntu 22.04
  2. Binding works initially. But after keeping the dev server running for a while (~1-2 hours) it starts showing the same error when getting requests that need to access the binding. I.e. Unhandled error: Error: head: Unspecified error (0) from:
const object = await env.example_bucket.head(this.objectKey);
  1. Kill dev server and restart with command from step 2 -> It works again for a while.

Let me know if you need more info.

Juuldamen avatar Sep 11 '25 14:09 Juuldamen

The same thing happens with range queries after some time of running.

Filyus avatar Oct 02 '25 08:10 Filyus

R2 error response does not contain the CF-R2-Error header.; response.statusCode = 500 JsError( "Error: Error: put: Unspecified error (0) - Cause: Error: put: Unspecified error (0)", ) [wrangler:info] POST /admin_api/upload/r2 200 OK (6653ms)

there are 400 code. i am 500 code.

using worker-rs.

ganluo960214 avatar Oct 31 '25 14:10 ganluo960214

I have this same issue, reading from R2 remote after a while of letting my local cf worker instance (wrangler dev) sit idle for a bit. I've set it up like this:

[[r2_buckets]]
binding = "R2_BUCKET"
bucket_name = "MY_BUCKET"
remote = true

Logs:

R2 error response does not contain the CF-R2-Error header.; response.statusCode = 400
[wrangler:error] Error: get: Unspecified error (0)

Tr1Fecta-7 avatar Nov 26 '25 23:11 Tr1Fecta-7

For me it started working after deleting .wrangler (cache) folder and restarting my server

Mukhammadali avatar Nov 30 '25 20:11 Mukhammadali

Glad I found this thread. I am having the exact same issue. Idle worker in dev --remote, idle 1h22 min, put Unspecified error. Restarted it and it works.

zdaar avatar Dec 08 '25 03:12 zdaar