Close SQLite connection in Next.js API routes for `next build` command to work?
So I got
Database is locked
error when I'm doing next build
like this when I'm building docker image. the command underneath is next build
which builds for production. this command calls all api routes:
my file is:
how do i solve this?
there is a .close()
on client but not on db
? there's a singleton pattern which i haven't tried for sqlite.
what would you do?
i believe this should work & it does locally at least but not with docker.
the problem is it sometimes builds perfectly & randomly fails when i delete previously build. so its hard to debug.1 Reply
i think i managed to fix this issue i guess.
its either because of me using default export
export default db
(i use this now) instead of named export export const db
like above or singleton pattern using https://github.com/epicweb-dev/remember
i'll have to debug but this essentially solved it for my docker version.
i'll push the whole working code on https://github.com/deadcoder0904/easypanel-nextjs-sqlite soon
my current problem is only to fix the drizzle migrations copying in the dockerfile
which is a big hard to debug even with docker exec -it 12141 sh
i removed export default db
& @epic-web/remember
and it still runs fine. i guess the issue was something else entirely but you can find it on my repo.