Closed db-cloudflare closed 2 weeks ago
I cannot reproduce this. I followed the following steps:
pnpm create-cloudflare@latest
[vars]
ASSETS = "production_value"
app.get("/", (c) => {
return c.text("Hello Hono!" + c.env.ASSETS);
Working at https://holy-block-8fb2.petebd.workers.dev
Apologies, I should have been more specific with the type of binding involved. In this case, it was an R2 binding with the binding name as ASSETS like the following that resulted in an error when deploying:
[[r2_buckets]] binding = "ASSETS" bucket-name = "static-assets"
I think this is a problem specifically with pages, is that right @dbenCF?
Oh right. Hono created via C3 is for Workers. But yes, I expect that ASSETS is blocked in Cloudflare Pages. Let me try to recreate it...
OK I managed to recreate this, I think. I don't think this has anything to do with Hono or R2. I think that any Pages project that is configured with a wrangler.toml that has an ASSETS
binding (of any kind) will error with an output that looks like:
pnpm wrangler pages deploy
๐ Uploading... (1/1)
โจ Success! Uploaded 0 files (1 already uploaded) (0.16 sec)
โจ Compiled Worker successfully
โจ Uploading Worker bundle
๐ Deploying...
โ [ERROR] Deployment failed!
Failed to publish your Function. Got error: Unknown internal error occurred.
Indeed I can recreate this with the following files:
_worker.js
export default {
fetch(_req, env) {
return new Response(env.ASSETS);
},
};
package.json
{
"name": "test"
}
wrangler.toml
name = "test"
pages_build_output_dir = "."
[vars]
ASSETS = "test"
Then running
pnpx wrangler pages deploy
โ Select an account โบ Pete Bacon Darwin Account
๐ Uploading... (2/2)
โจ Success! Uploaded 1 files (1 already uploaded) (1.22 sec)
โจ Compiled Worker successfully
โจ Uploading Worker bundle
๐ Deploying...
โ [ERROR] Deployment failed!
Failed to publish your Function. Got error: Unknown internal error occurred.
Really we should be getting a better error back from the API when this fails, but we could perhaps put an additional validation check into Wrangler.
Which Cloudflare product(s) does this pertain to?
Pages
What version(s) of the tool(s) are you using?
Wrangler 3.64.0
What version of Node are you using?
20.10.0
What operating system and version are you using?
Windows 11
Describe the Bug
Observed behavior
When deploying a Hono application in Wrangler, if a binding uses the name 'ASSETS' the application will fail to deploy.
Expected behavior
The application failing to deploy is expected as assets is a reserved keyword, however no error message is provided to explain that this is the cause of the failed deployment. An error message that explains that a binding with the name assets exists and that the name needs to be changed is the expected behavior.
Steps to reproduce
Please provide the following: