Open majames opened 3 months ago
I have the exact same issue in Nuxt 3 Pages project bound (using nitro-cloudflare-dev module) to a Durable Object in a separate wrangler worker project.
I'm hitting the same thing:
const doId = CHATSTORE.idFromName(`chat-${id}`);
const doStub = CHATSTORE.get(doId);
const doResponse = await doStub.fetch(new Request("http://foo/"));
This fails on the fetch
because that line of code expects a string (URL), not a Request
object. In this case, I can pass a string instead of a Request
, but when I want to write to the DO, that workaround doesn't work:
return doStub.fetch(
new Request(`http://foo${path}`, {
method: "PUT",
body: JSON.stringify(value),
})
);
Following the chain of calls, it looks like this argument gets passed to https://github.com/cloudflare/workers-sdk/blob/c643a8193a3c0739b33d3c0072ae716bc8f1565b/packages/miniflare/src/http/request.ts#L33 which then passes the Request to the Undici Request initializer, which doesn't appear to take a Request but wants a URL?
Which Cloudflare product(s) does this pertain to?
Pages, Miniflare
What version(s) of the tool(s) are you using?
3.57.0 (wrangler), 3.20240512.0 (miniflare), 1 (@cloudflare/next-on-pages)
What version of Node are you using?
20.13.1
What operating system and version are you using?
Mac Sonoma 14.5
Describe the Bug
Observed behavior
I have a
app/ws/route.ts
GET handler that attempts to pass therequest
object to a durable objects (DO)fetch
method.This is result in the following issue:
This issue seems very similar to https://github.com/cloudflare/miniflare/issues/454 however I'm on wrangler
3
. After tracing it through in the debugger:Expected behavior
The request to be successfully passed to the DO.
Steps to reproduce
Follow next-on-pages dev guide to setup a dummy DO and observe the error.