miniflare: Failed to parse URL from [object Object]
I just tried to upgrade to v2 and hit /, which I have mapped to a 404 (but any of my previously working endpoints fail as well). I have no idea why this is failing now.
My code is dead simple:

The error is:

Seems like there are two bits here… a problem with miniflare and giving feedback to your upstream dependency undici to display a more helpful error than trying to blindly concat a string and an object.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
Confirmed with my production worker. Thanks!
Just fixed! 👍 That’s exactly what I did. 🙂 Thanks @merceyz for explaining this, that does make sense.
Hey everyone! 👋 I’ve spent most the afternoon trying to debug this and I haven’t been able to fix it. Yarn PnP seems pretty cool, but to me at least, it’s very opaque and hard to debug. I’ll share what I’ve found so far. I would be very happy to accept a PR fixing this, but I don’t think I’m going to spend any more time myself trying to fix this, as it works with
npm/pnpm/Yarn 1.The problem is caused by this line:
https://github.com/cloudflare/miniflare/blob/541e21893160087602e9443c3ed39147df0d912a/packages/core/src/standards/http.ts#L372-L373
It looks like 2 versions of
@miniflare/coreare being loaded, soinputis an instance of aRequestclass from a different@miniflare/coreversion. This causes our custom-Requestclass to be passed toundici(via thenew BaseRequestconstructor), which isn’t an instanceof ofundici’s (Base)Requestclass, so it just stringifies it as a URL, hence the[object Object].This can be seen in the
.pnp.jsfile: (NOTE: some of the hashes/versions might be different, this is my development version with uncommitted changes).pnp.js["@miniflare/core", [ ["npm:2.0.0", { "packageLocation": "./.yarn/cache/@miniflare-core-npm-2.0.0-eb145c8dfa-851c85954a.zip/node_modules/@miniflare/core/", "packageDependencies": [ ["@miniflare/core", "npm:2.0.0"] ], "linkType": "SOFT", }], ["virtual:4612a3e4318f1d4532829ddfea859ddb4033714894b6ebbf06109a0a1089d0526e59f6758bfd5de89902c9d9ec4a226d7928e940dcdb21d9affb89a876898a6c#npm:2.0.0", { "packageLocation": "./.yarn/$$virtual/@miniflare-core-virtual-2a535e900b/0/cache/@miniflare-core-npm-2.0.0-eb145c8dfa-851c85954a.zip/node_modules/@miniflare/core/", "packageDependencies": [ ["@miniflare/core", "virtual:4612a3e4318f1d4532829ddfea859ddb4033714894b6ebbf06109a0a1089d0526e59f6758bfd5de89902c9d9ec4a226d7928e940dcdb21d9affb89a876898a6c#npm:2.0.0"], ["@iarna/toml", "npm:2.2.5"], ["@miniflare/shared", "npm:2.0.0"], ["@miniflare/watcher", "npm:2.0.0"], ["@types/miniflare__watcher", null], ["busboy", "npm:0.3.1"], ["dotenv", "npm:10.0.0"], ["kleur", "npm:4.1.4"], ["set-cookie-parser", "npm:2.4.8"], ["undici", "npm:4.12.1"] ], "packagePeers": [ "@miniflare/watcher", "@types/miniflare__watcher" ], "linkType": "HARD", }], ["virtual:b426922761b424d6f41e8750de53fe1bbd08be0031a15530893ce688ab42c2d19a24361dcc8a170fff10c826074fd448e42a18b2df75b625602417ddee5354ef#npm:2.0.0", { "packageLocation": "./.yarn/$$virtual/@miniflare-core-virtual-36f87c2a4c/0/cache/@miniflare-core-npm-2.0.0-eb145c8dfa-851c85954a.zip/node_modules/@miniflare/core/", "packageDependencies": [ ["@miniflare/core", "virtual:b426922761b424d6f41e8750de53fe1bbd08be0031a15530893ce688ab42c2d19a24361dcc8a170fff10c826074fd448e42a18b2df75b625602417ddee5354ef#npm:2.0.0"], ["@iarna/toml", "npm:2.2.5"], ["@miniflare/shared", "npm:2.0.0"], ["@miniflare/watcher", null], ["@types/miniflare__watcher", null], ["busboy", "npm:0.3.1"], ["dotenv", "npm:10.0.0"], ["kleur", "npm:4.1.4"], ["set-cookie-parser", "npm:2.4.8"], ["undici", "npm:4.12.1"] ], "packagePeers": [ "@miniflare/watcher", "@types/miniflare__watcher" ], "linkType": "HARD", }] ]],The first gets used by the
miniflarepackage:["miniflare", [ ["npm:2.0.0", { "packageLocation": "./.yarn/cache/miniflare-npm-2.0.0-138d8a5ee0-ddcb0178d9.zip/node_modules/miniflare/", "packageDependencies": [ ["miniflare", "npm:2.0.0"] ], "linkType": "SOFT", }], ["virtual:ebc911dbdf8f37abd4dca2dced16a945d12f0ef0299f18a05a9e3fb50e0507f0ee90b326660e6d343db4fd3fbed72a138d577eac1b2afc578382fe9fbacf8915#npm:2.0.0", { "packageLocation": "./.yarn/$$virtual/miniflare-virtual-4612a3e431/0/cache/miniflare-npm-2.0.0-138d8a5ee0-ddcb0178d9.zip/node_modules/miniflare/", "packageDependencies": [ ... ["@miniflare/core", "virtual:4612a3e4318f1d4532829ddfea859ddb4033714894b6ebbf06109a0a1089d0526e59f6758bfd5de89902c9d9ec4a226d7928e940dcdb21d9affb89a876898a6c#npm:2.0.0"], ...…and the second gets used by everything else:
["@miniflare/durable-objects", [ ["npm:2.0.0", { "packageLocation": "./.yarn/cache/@miniflare-durable-objects-npm-2.0.0-f066b4d653-a01cbf6eb4.zip/node_modules/@miniflare/durable-objects/", "packageDependencies": [ ... ["@miniflare/core", "virtual:b426922761b424d6f41e8750de53fe1bbd08be0031a15530893ce688ab42c2d19a24361dcc8a170fff10c826074fd448e42a18b2df75b625602417ddee5354ef#npm:2.0.0"], ... ], "linkType": "HARD", }] ]],Patching
.pnp.jsto log module cache misses also shows this:I would expect only 1 cache miss, but I see 2:
I’ve tried defining
@miniflare/coreas apeerDependencyinminiflarebut that just causes issues with the installation.Any assistance/PRs would be greatly appreciated 🙂
Are you using Yarn PnP? This happens for me with Yarn PnP.