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

Cloudflare Adapter: Build fails while finalizing server assets #13163

Closed
1 task
MehrdadKhnzd opened this issue Nov 12, 2024 · 5 comments
Closed
1 task

Cloudflare Adapter: Build fails while finalizing server assets #13163

MehrdadKhnzd opened this issue Nov 12, 2024 · 5 comments
Labels
needs repro Issue needs a reproduction pkg: cloudflare Related to the Cloudflare adapter

Comments

@MehrdadKhnzd
Copy link

Astro Info

Astro                    v4.16.10
Node                     v20.18.0
System                   Linux (x64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             unocss
                         @astrojs/solid-js

Describe the Bug

This is a new project I'm building for the first time. After building the files and while finalizing server assets and Rearranging server assets... it throws an error:

ENOENT: no such file or directory, open '/<path>/dist/_worker.js/_astro/Page.O6jLfjx6.js'
 Location:
    /home/mehrdad/avid-ai/node_modules/@astrojs/cloudflare/dist/utils/cloudflare-module-loader.js:156:34

It seems that the file that it's looking for is under /dist/_astro not /dist/_worker.js/_astro - there is no _astro folder inside _worker.js and I don't understand why this happens, either the build step in vite puts the stuff in the wrong place:

building client (vite) 
04:04:32 [vite] ✓ 26 modules transformed.
04:04:32 [vite] dist/_astro/client.DP_eMiOr.js    0.99 kB │ gzip:  0.60 kB
04:04:32 [vite] dist/_astro/Page.rkUIeSSz.js     12.82 kB │ gzip:  4.30 kB
04:04:32 [vite] dist/_astro/store.B9wgTa3t.js    19.76 kB │ gzip:  7.73 kB
04:04:32 [vite] dist/_astro/Page.O6jLfjx6.js     72.71 kB │ gzip: 21.60 kB
04:04:32 [vite] ✓ built in 1.08s

Or there's an issue with afterBuildCompleted.

Thanks for your help, please let me know what you think.

What's the expected result?

It should build the project normally.

Link to Minimal Reproducible Example

I couldn't recreate it using a minimal reproduction, but I can try again to do so if the error is not recognizable.

Participation

  • I am willing to submit a pull request for this issue.
@alexanderniebuhr
Copy link
Member

Thanks for the report. I know we had such issue with an old version of the adapter, but the newest release should not have it anymore. Can you please try to add a minimal reproduction, which shows the errors on latest versions?

@alexanderniebuhr alexanderniebuhr added the needs repro Issue needs a reproduction label Nov 12, 2024
@MehrdadKhnzd
Copy link
Author

@alexanderniebuhr I found the error. It's because I have imported a text file in my TSX file:

import file from '../files/text.txt'

This is a minimal repro. If you comment out the import in Page.tsx, it will build successfully. Otherwise, it will fail.
https://stackblitz.com/~/github.com/MehrdadKhnzd/astro-cloudflare-text-import-bug-repro

On a more minimal reproduction, I wasn't able to recreate this error by importing text, so I'm not sure what all the parameters that affect it are:
https://stackblitz.com/edit/github-7vggel?file=src%2Fpages%2F_%2FPage.tsx

Thanks!

@alexanderniebuhr alexanderniebuhr removed the needs repro Issue needs a reproduction label Nov 13, 2024
@alexanderniebuhr
Copy link
Member

Thanks for the reproductions, I'll try to figure out the root cause.

@ematipico ematipico transferred this issue from withastro/adapters Feb 7, 2025
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 7, 2025
@ematipico ematipico added the pkg: cloudflare Related to the Cloudflare adapter label Feb 7, 2025
@florian-lefebvre
Copy link
Member

This may be fixed with the latest version of the integration, can you try again and provide an updated reproduction if the issue persists?

@florian-lefebvre florian-lefebvre added the needs repro Issue needs a reproduction label Feb 14, 2025
Copy link
Contributor

Hello @MehrdadKhnzd. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Feb 14, 2025
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue needs a reproduction pkg: cloudflare Related to the Cloudflare adapter
Projects
None yet
Development

No branches or pull requests

4 participants