Skip to content
New issue

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

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

Already on GitHub? # to your account

[D1] πŸš€ Feature Request: Intercept the dev server error "binding DB of type d1 must have a valid id specified", make it clearer #4590

Closed
rozenmd opened this issue Dec 12, 2023 · 0 comments Β· Fixed by #4914
Labels
d1 Relating to D1 enhancement New feature or request quick win Potentially easy/straightforward issue to tackle

Comments

@rozenmd
Copy link
Contributor

rozenmd commented Dec 12, 2023

Describe the solution

If you attempt to run wrangler dev --remote with preview_database_id set to a random string that doesn't exist, you get a big scary error:

✘ [ERROR] Error on remote worker: ParseError: A request to the Cloudflare API (/accounts/xxxxxx/workers/scripts/d1-test/edge-preview) failed.

      at throwFetchError
  (/d1-test/node_modules/wrangler/wrangler-dist/cli.js:119636:17)
      at fetchResult
  (/d1-test/node_modules/wrangler/wrangler-dist/cli.js:119555:5)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async createPreviewToken
  (/d1-test/node_modules/wrangler/wrangler-dist/cli.js:148372:29)
      at async createWorkerPreview
  (/d1-test/node_modules/wrangler/wrangler-dist/cli.js:148393:17)
      at async start
  (/d1-test/node_modules/wrangler/wrangler-dist/cli.js:148962:34) {
    text: 'A request to the Cloudflare API
  (/accounts/xxxxxx/workers/scripts/d1-test/edge-preview) failed.',
    notes: [
      {
        text: 'binding DB of type d1 must have a valid `id` specified [code: 10021]'
      }
    ],
    location: undefined,
    kind: 'error',
    code: 10021
  }

The only way you'd get this error is if the database doesn't exist, so we should just tell folks to use a real database here.

Attempting to deploy a Worker with a fake ID throws the same error, so we could make that nicer too.

@rozenmd rozenmd added enhancement New feature or request d1 Relating to D1 labels Dec 12, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Dec 12, 2023
@rozenmd rozenmd added the quick win Potentially easy/straightforward issue to tackle label Dec 12, 2023
@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Feb 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
d1 Relating to D1 enhancement New feature or request quick win Potentially easy/straightforward issue to tackle
Projects
None yet
1 participant