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

🐛 BUG: d1 local migrations erroring #3964

Closed
ukd1 opened this issue Sep 16, 2023 · 2 comments
Closed

🐛 BUG: d1 local migrations erroring #3964

ukd1 opened this issue Sep 16, 2023 · 2 comments
Labels
bug Something that isn't working

Comments

@ukd1
Copy link

ukd1 commented Sep 16, 2023

Which Cloudflare product(s) does this pertain to?

D1

What version(s) of the tool(s) are you using?

3.8.0

What version of Node are you using?

v18.7.0

What operating system are you using?

Mac

Describe the Bug

Local migrations (#2246) don't work for me, but I have a working setup otherwise.

% wrangler d1 migrations apply PARCEL_DB        

✅ No migrations to apply!

Try to apply locally.....

% wrangler d1 migrations apply PARCEL_DB --local          

✘ [ERROR] Could not locate the bindings file. Tried:

   → /Users/russ/.../web/node_modules/better-sqlite3/build/better_sqlite3.node
   → /Users/russ/.../web/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
   → /Users/russ/.../web/node_modules/better-sqlite3/build/Release/better_sqlite3.node
   → /Users/russ/.../web/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
   → /Users/russ/.../web/node_modules/better-sqlite3/Debug/better_sqlite3.node
   → /Users/russ/.../web/node_modules/better-sqlite3/out/Release/better_sqlite3.node
   → /Users/russ/.../web/node_modules/better-sqlite3/Release/better_sqlite3.node
   → /Users/russ/.../web/node_modules/better-sqlite3/build/default/better_sqlite3.node
   →
  /Users/russ/.../web/node_modules/better-sqlite3/compiled/18.7.0/darwin/arm64/better_sqlite3.node
   →
  /Users/russ/.../web/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
   →
  /Users/russ/.../web/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
   →
  /Users/russ/.../web/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
   →
  /Users/russ/.../web/node_modules/better-sqlite3/lib/binding/node-v108-darwin-arm64/better_sqlite3.node

error: "wrangler" exited with code 1 (SIGHUP)

wrangler.toml:

name = "xxx"
main = "src/index.ts"
compatibility_date = "2023-03-30"

route = "xxxx.xxxxx.com/*"
vars = { ENVIRONMENT = "dev" }

d1_databases = [
    { binding = "PARCEL_DB", database_name = "xxxx", database_id = "xxxxxxxx" },
]

The db exists, I just can't apply a new migration:

% find .wrangler 
.wrangler
.wrangler/state
.wrangler/state/d1
.wrangler/state/v3
.wrangler/state/v3/d1
.wrangler/state/v3/d1/<the same database_id from my toml>
.wrangler/state/v3/d1/<the same database_id from my toml>/db.sqlite
.wrangler/state/v3/d1/<the same database_id from my toml>/db.sqlite-wal
.wrangler/state/v3/d1/<the same database_id from my toml>/db.sqlite-shm

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@ukd1 ukd1 added the bug Something that isn't working label Sep 16, 2023
@ukd1 ukd1 changed the title 🐛 BUG: 🐛 BUG: d1 local migrations erroring Sep 16, 2023
@ukd1
Copy link
Author

ukd1 commented Sep 16, 2023

fyi this seemed to (but could be something else?) happen when I upgraded to 3.8.0 from 3.5.1. After restarting wrangler dev I get a similar error....

{"status":500,"error":"D1_ERROR: Failed to parse body as JSON, got: Error: Could not locate the bindings file. Tried:\

Downgrading to 3.5.1 didn't fix it.

@ukd1
Copy link
Author

ukd1 commented Sep 16, 2023

So, I nuked the node_modules and reinstalled, and it's working. I read folks having similar issues over at WiseLibs/better-sqlite3#1058 & WiseLibs/better-sqlite3#1034 and it said there were binaries involved, and some fixed by reinstalling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant