Error deploying pages project to preview environment

I'm using Cloudflare Pages to host a SvelteKit project, using @sveltejs/adapter-cloudflare and Git Integration. Whenever a non-main branch is published/updated, I get the following error on the Preview Deployment Build Log:
Error: Failed to publish your Function. Got error: binding db of type d1 must have a database that already exists. Use wrangler or the UI to create the database.
Error: Failed to publish your Function. Got error: binding db of type d1 must have a database that already exists. Use wrangler or the UI to create the database.
Most recently on deployment id: 0ca9aba3-eea8-4f2f-86c6-d9896b55328d - This code is identical to the current production deployment that's running just fine, just the result of creating a new branch in GitHub. The project settings appear to be identical between the production and preview branches. I'm not using d1, my SvelteKit project does not contain a wrangler file, and there aren't any bindings in the project settings. I get zero errors when building locally and running
wrangler pages dev .svelte-kit/cloudflare
wrangler pages dev .svelte-kit/cloudflare
The last preview deployment that was successful was aa5a2e15-4bc1-4f40-a685-fd5297f5fa25, from 9 days ago.
1 Reply
mort
mortOP13mo ago
I tried re-deploying deployment aa5a2e15-4bc1-4f40-a685-fd5297f5fa25 that had successfully deployed as preview, and it failed with the same error as well. Is there a way to see what the project settings were previously set to? I duplicated the repo and started a new Cloudflare Pages project using the new repo. The preview branch deploys flawlessly. I'm really confused as to what could be causing the issue. I went through all of the settings and they match between projects (aside from the workers compatibility date set to today on the new project).
At least now I know I should be able to delete the project that's failing to deploy previews and re-create it, but I'd rather not have to lose all of the historical data associated with that project. Apparently I had somehow established a D1 binding in the preview settings to a D1 database I was experimenting with in another workers project. Deleting the D1 database without first removing the binding created the issue. The binding was hidden on the dashboard because there was not a D1 database which made it difficult to diagnose. Creating a temporary D1 database and going back to the project settings revealed the binding and allowed me to delete it, and then the D1 database.
Want results from more Discord servers?
Add your server