workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Vite Plugin error after saving the entrypoint file twice

Open jfromaniello opened this issue 7 months ago • 2 comments

Which Cloudflare product(s) does this pertain to?

Vite Plugin

What versions & operating system are you using?

Wrangler 4.13.2, @cloudflare/vite-plugin 1.0.8, node 22

Please provide a link to a minimal reproduction

https://github.com/cloudflare/agents-starter

Describe the Bug

Changing the main entry point file triggers a rebuild in vite, if you save the file again while building then fails with the following error:

[vite] Internal server error: /path/to/file.ts does not export a default entrypoint.

Which is not true. The file does contains a default entry point.

It seems there is a race condition.

Please provide any relevant error logs

Clone the cloudflare/agents-starter repo or run to create a version of it

npm create cloudflare@latest -- --template cloudflare/agents-starter

then run :

npm install
npm run start

while the project is running, try the following command:

echo >> ./src/server.ts ; sleep 1 ; echo >> ./src/server.ts

once vite enters this state, there is no way to fix it other than restarting vite dev.

jfromaniello avatar Apr 25 '25 18:04 jfromaniello

I'm not able to reproduce this and the linked issue has been closed. Are you able to confirm if this is still an issue? Thanks.

jamesopstad avatar Jun 02 '25 13:06 jamesopstad

I'm not able to reproduce this and the linked issue has been closed. Are you able to confirm if this is still an issue? Thanks.

Hey. This still happens to me on v4.19.2

When I make changes to worker file at src/worker.ts during wrangler dev --remote, it'll reupload things fast and then vite will throw this error. Only way is to restart vite server

maiznadeem avatar Jun 12 '25 10:06 maiznadeem

I'm not able to reproduce this and the linked issue has been closed. Are you able to confirm if this is still an issue? Thanks.

Hey. This still happens to me on v4.19.2

When I make changes to worker file at src/worker.ts during wrangler dev --remote, it'll reupload things fast and then vite will throw this error. Only way is to restart vite server

I might be missing something, could you clarify what your development workflow is and how wrangler dev --remote relates to vite there?

Also, if you could provide a minimal (consistent) reproduction that would be really helpful 🙏

dario-piotrowicz avatar Jun 23 '25 13:06 dario-piotrowicz

I might be missing something, could you clarify what your development workflow is and how wrangler dev --remote relates to vite there?

I'm using the @cloudflare/vite-plugin, experiencing the exact same thing as OP does. When you clone https://github.com/cloudflare/agents-starter and try to make changes fast, it tries to upload each change one by one and then you get an error just like OP described. Only way is to restart vite server.

maiznadeem avatar Jun 24 '25 09:06 maiznadeem

I wonder if this is related to https://github.com/cloudflare/workers-sdk/issues/9518

petebacondarwin avatar Jul 07 '25 12:07 petebacondarwin

@maiznadeem Are you able to provide steps to reproduce? I have a PR up (https://github.com/cloudflare/workers-sdk/pull/10001) that I suspect might fix this but I'm unable to confirm without a reproduction. Thanks.

jamesopstad avatar Jul 17 '25 11:07 jamesopstad

hi @jfromaniello and @maiznadeem :) we believe this should now be fixed with https://github.com/cloudflare/workers-sdk/pull/10001, so we're going to close this issue. if you're still running into problems, please feel free to open a new issue referencing this one. please be sure to include an updated summary and a repro and will revisit and investigate further. thanks!

lrapoport-cf avatar Aug 04 '25 13:08 lrapoport-cf