Regression in wrangler 3.46.0: Accessing a Durable Object in another locally running Worker Project

We noticed a regression in accessing a Durable Object in another Worker Project when runnig locally after upgrading to 3.46.0. After this upgrade all calls to the Durable Object are failing with opaque errors. All responses result in a 500 without useful response bodies or headers. We used the following approach to enable a locally running Worker to call another locally running Worker. With this approch we were able to start the two workers locally using wrangler dev and have them communicate with each other.
##############################
# Local Dev Environment
name = "accelerate-edge-local"
durable_objects.bindings = [
# This script_name is important so that this worker talks to the local tenant manager.
# If there's a deployed version with the same name, wrangler dev would talk to the deployed version.
# Hence we use special names only locally.
{ name = "TENANT_MANAGER", class_name = "TenantManager", script_name = "tenant-manager-local" }
]
##############################
# Local Dev Environment
name = "accelerate-edge-local"
durable_objects.bindings = [
# This script_name is important so that this worker talks to the local tenant manager.
# If there's a deployed version with the same name, wrangler dev would talk to the deployed version.
# Hence we use special names only locally.
{ name = "TENANT_MANAGER", class_name = "TenantManager", script_name = "tenant-manager-local" }
]
With this config we were calling the worker with:
const doid = c.env.TENANT_MANAGER.idFromString(apiKey.tenant_id);
const stub = c.env.TENANT_MANAGER.get(doid);
stub.fetch(...)
const doid = c.env.TENANT_MANAGER.idFromString(apiKey.tenant_id);
const stub = c.env.TENANT_MANAGER.get(doid);
stub.fetch(...)
However this approach does not work anymore. Are there any known workarounds for this?
2 Replies
mavilein
mavileinOP8mo ago
I was able to reproduce this and submitted a bug report here: https://github.com/cloudflare/workers-sdk/issues/5623 To anyone stumbling upon this thread. Here is the culprit and a workaround. All calls to stub.fetch with the following shape fail:
const response = await stub.fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body,
});
const response = await stub.fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body,
});
We were able to unblock ourselves by copying over the cf property. The absence of this property leads to crashes in workerd/miniflare.
const response = await stub.fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body,
// if the following gets copied over it works again
cf: request.cf
});
const response = await stub.fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body,
// if the following gets copied over it works again
cf: request.cf
});
GitHub
🐛 BUG: · Issue #5623 · cloudflare/workers-sdk
Which Cloudflare product(s) does this pertain to? Wrangler core, Miniflare What version(s) of the tool(s) are you using? 3.46.0 What version of Node are you using? 21.7.3 What operating system and ...
danecando
danecando8mo ago
So glad I found this thread. I was struggling with this one quite a bit 🙏
Want results from more Discord servers?
Add your server