Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Workers with Static Assets Local Dev Error (npx wrangler dev) #7277

Closed
flikteoh opened this issue Nov 18, 2024 · 12 comments
Closed
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working Workers + Assets

Comments

@flikteoh
Copy link

flikteoh commented Nov 18, 2024

Which Cloudflare product(s) does this pertain to?

C3 (npm create cloudflare), Workers Runtime, Wrangler

What version(s) of the tool(s) are you using?

3.87.0 [Wrangler], 2.32.1 [C3]

What version of Node are you using?

22.3.0

What operating system and version are you using?

macOs Sequoia 15.1

Describe the Bug

Observed behavior

Running npx wrangler dev causes error on both existing Qwik project and newly created Qwik project via C3.
It was expecting the _worker.js file to have already been built.

✘ [ERROR] The entry-point file at "dist/_worker.js" was not found.

This seems to work for Pages via npx wrangler pages dev but not for workers with assets npx wrangler dev. Is there planned support in the future?

Update: the npx wrangler pages dev returns empty/404 pages for Qwik.

Expected behavior

Be able to work with supported service bindings locally with Qwik framework via npx wrangler dev

https://developers.cloudflare.com/workers/frameworks/framework-guides/qwik/

Steps to reproduce

  • npm create cloudflare@latest my-qwik-app -- --framework=qwik --experimental
  • cd my-qwik-app
  • npx wrangler dev
  • Error displayed

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

my-qwik-app✨npx wrangler dev

 ⛅️ wrangler 3.87.0
-------------------


✘ [ERROR] The entry-point file at "dist/_worker.js" was not found.
@flikteoh flikteoh added the bug Something that isn't working label Nov 18, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Nov 18, 2024
@CarmenPopoviciu
Copy link
Contributor

CarmenPopoviciu commented Nov 18, 2024

hi @flikteoh ,

thank you for raising this issue with us. When you created your Qwik project, did you follow the steps described in https://developers.cloudflare.com/workers/frameworks/framework-guides/qwik/? There are some subtle differences between scaffolding Pages + Frameworks projects vs Workers + Assets + Frameworks projects.

Can you please have a look, and in case you haven't used that process, can you please try setting up a new Qwik project as per those instructions and let us know if you are still experiencing issues 🙏 ?

@CarmenPopoviciu CarmenPopoviciu added awaiting reporter response Needs clarification or followup from OP and removed Workers + Assets labels Nov 18, 2024
@flikteoh
Copy link
Author

Hey @CarmenPopoviciu,
Thanks for the prompt respond.

I have followed the steps described in the documentation multiple times by using existing project, and creating multiple new worker with assets projects (qwik, astro) and also tried the cloudflare pages approach with new pages project.

For workers, it just expects there’s a _worker.js file during npx wrangler dev. But I assume it was suppose to work with Qwik’s dev server instead of product built files? Am I doing anything wrong?

For pages project, I created new ones using Qwik, added the bindings for testing purposes and npx wrangler pages dev returns 404 in terminal and empty page.

Thank you

@CarmenPopoviciu
Copy link
Contributor

CarmenPopoviciu commented Nov 18, 2024

In the Qwik framework guide, I'm seeing that to start local dev the command to be run is npm run dev, but you seem to be running wrangler dev directly? Have you tried npm run dev?

@flikteoh
Copy link
Author

Yes I did tried that too. It would just run the dev server for Qwik without the service binding locally.

What I’m trying to achieve is to be able to run the qwik dev server locally with service bindings locally. There seems to be so documentation mix up:

What would be the correct script for the npm run dev?

@CarmenPopoviciu
Copy link
Contributor

CarmenPopoviciu commented Nov 18, 2024

hi @flikteoh,

ok, so I went ahead and followed the steps myself as per the guide I linked you, just so I can see what you see :). Everything in the guide is correct, except that running npm run dev will not build the application for you, which is why you are seeing that The entry-point file at "dist/_worker.js" was not found. error. What you can do is either run npm run preview, preview being a s script defined in package.json that was generated by C3, or you can build the project yourself via npm run build, then run wrangler dev.

Can you please try one of these out and let me know if that fixed the issue for you?

@flikteoh
Copy link
Author

flikteoh commented Nov 19, 2024

Hi @CarmenPopoviciu,

I understand that running npm run build/preview would build the _worker.js file. But that would defeat the purpose of developing locally with HMR? Do we then have to rebuild manually on every file changes?

Does this mean that it is not possible to work directly with bindings locally via npm run dev without the _worker.js file?

Here's the article from Cloudflare that I was referring to: https://blog.cloudflare.com/blazing-fast-development-with-full-stack-frameworks-and-cloudflare/

I’m trying to understand what is the correct steps, because I’ve tried creating new project using Astro template with same error.

Normally when building locally with npm run dev, there’s live reload HMR, and there’s no production build files. The only piece that is missing now is that we can't access the "local" version of service bindings.

For example:

Your worker has access to the following bindings:
- KV Namespaces:
  - config: 1ad9846ac65e494c8661db45eed03880 (local)
[wrangler:inf] Ready on http://localhost:8788

The above is run via npx wrangler pages dev, except the Astro/Qwik pages doesn't have access to the KV or the local project is 404.

Thank you

@flikteoh
Copy link
Author

flikteoh commented Nov 19, 2024

Update:

I actually found that running npm run dev is the correct way to work locally with Cloudflare. You're right about following the instructions as per documentation for Workers with Assets for Qwik. Sorry for wasting your time @CarmenPopoviciu ! 🙇🏻

I also wanted to use npx wrangler dev --remote (which I think only works with regular CF Worker) so I can test developments on remote services. But the blog post and documentation were also right about Cloudflare Pages doesn't currently support Remote Development (--remote) while there is some confusion here.

screen

Apart from these, I guess there may be also some issues with the adapter implementations in Qwik framework, specifically with cache not defined. Looking into the current repo, I think it may not have been implemented yet.

Sorry for the time though! Do let me know if I should close this issue!

@CarmenPopoviciu
Copy link
Contributor

No worries at all @flikteoh !! I saw your followup but didn't have time to reply just yet. Turns out you figured it out and I'm very glad it works for you now 🎉

wrangler dev --remote is not supported yet for Workers with Assets, but we are actively working on it. We should have something up and running soon so keep your eyes on the repo. There's a POC out and about at the moment, if you reeeeeeeeally want to try it out, but I'd advise waiting for an official PR to land in the repo, mainly because, as it usually goes with POCs, much of the details in there might change in the final implementation.

As for the adapter implementations, indeed some things may not be supported just yet, as Framework support is somewhat experimental. The Workers with Assets feature itself is still in beta. But we are working on solidifying the experience, and all loose ends, as we move towards going out of beta.

Thank you again for raising the issue with us, and really glad it worked out in the end. I'll go ahead and close this

<3

@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Nov 19, 2024
@flikteoh
Copy link
Author

As for the adapter implementations, indeed some things may not be supported just yet, as Framework support is somewhat experimental. The Workers with Assets feature itself is still in beta. But we are working on solidifying the experience, and all loose ends, as we move towards going out of beta.

Is the cache and cf object not working already via getPlatformProxy API or is it not yet supported in Workers with Assets?

I was thinking it only needs to be implemented by the Qwik framework. Currently, cache api works when deployed just not in local dev server.

@petebacondarwin
Copy link
Contributor

It looks like we are not wiring up the cf property for Qwik right now:

const newBody = [
["env", "Env"],
// Qwik doesn't supply `cf` to the platform object. Should they do so, uncomment this
// ["cf", "CfProperties"],
].map(([varName, type]) =>

@petebacondarwin
Copy link
Contributor

And looks like Qwik still does not yet support cf:

https://github.com/QwikDev/qwik/blob/7558018276e76441570c379351d7b3973b748fa4/packages/qwik-city/src/middleware/cloudflare-pages/index.ts#L144-L148

@flikteoh
Copy link
Author

flikteoh commented Nov 19, 2024

Thank you for the info @petebacondarwin
Is the cache included only via getPlatformProxy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working Workers + Assets
Projects
Status: Done
Development

No branches or pull requests

3 participants