Cloudflare Pages: "Failed: an internal error occurred"

Hello! I’m trying to build a very basic cloudflare pages app with Sveltekit. Everything seems like it should be working, but instead I am getting the rather unhelpful error of Failed: an internal error occurred right after the Deploying your site to Cloudflare's global network... step.

Does anybody know how to even begin to debug this?

The most common cause of this error right now is incorrect build output folder. Please make sure to double check that

That was it. Thank you!

Actually, @WalshyMVP , that doesn’t seem to be it. I thought that was the case as changing the directory to something else did deploy - but that was a separate build step in the svelte application.

As far as I can tell, this problem seems to be related to my use of firebase in the generated code. I can get it to compile correctly as long as I set { platform: 'node' } inside of the options for the cloudflare packager - but it always fails with some sort of internal error on the deploy step.

1 Like

Had the same issue

23:43:08.787	> Using @sveltejs/adapter-cloudflare
23:43:08.849	  ✔ done
23:43:08.869	Finished
23:43:08.869	Note: No functions dir at /functions found. Skipping.
23:43:08.869	Validating asset output directory
23:43:10.590	Deploying your site to Cloudflare's global network...
23:43:17.016	Failed: an internal error occurred

Since Cloudflare isn’t giving me a descriptive error and I’m on the free tier, it looks like I’m stuck.

Did you see my last message regarding this? The most common cause is still the output folder being incorrect. Please make 100% sure it’s set correctly

1 Like

I’m getting the same vague error at the final stage:

15:38:22.461	Deploying your site to Cloudflare's global network...
15:38:24.383	Failed: an internal error occurred

I have triple checked that the output folder is set to the correct value of .svelte-kit/cloudflare

Figured it out, it was user error. The config object in the svelte.config.js file looked like this:

const config = {
  preprocess: [preprocess({ postcss: true })],
  adapter: cloudflare(),
  kit: {
    target: '#svelte'
  }
};

but it should have looked like this:

const config = {
  preprocess: [preprocess({ postcss: true })],
  kit: {
    adapter: cloudflare(),
    target: '#svelte'
  }
};

Once I correctly nested the adapter key inside the kit key it worked perfectly. :+1:

1 Like

Thanks @WalshyMVP. I got the same error message, and for me it was the output directory. I thought it was relative to the root of the site, but it’s relative to the Root directory config (if defined)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.