App Platform and SQLIte

I’m running into an issue trying to use SQLite as a cache for my Nextjs app. It’s needed because Nextjs builds each page in a worker, so data that needs to be shared is writing to a SQLite db in <root>/data/cache.sqlite3. This cache is recreated during the build step, so it’s ok for it to be ephemeral. This works great in development but I’m running into this error when trying to access it once deployed to App Platform:

frontend | 20:59:23 > Build error occurred
frontend | 20:59:23 [Error: SQLITE_IOERR: disk I/O error] {
frontend | 20:59:23   type: 'Error',
frontend | 20:59:23   errno: 10,
frontend | 20:59:23   code: 'SQLITE_IOERR'
frontend | 20:59:23 }

Is there a preferred directory for temp files on App Platform? What could be going on here?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

So this turned out to be an issue with too many writes occurring at once. I fixed this by adding some backoff + retry logic around those writes, which resolved the issue.