prisma.update returns promise but doesn't do anything (most of the time)
As described in the title, prisma.update does not reliably trigger an update in the database. This is the gist of my code:
.middleware(...) //<-- works just fine.onUploadComplete(({ file }) => { console.log("on upload complete") // <-- works just fine try { const promise = prisma.plant.update({ // <-- returns a promise where: { imageUrl: file.url }, data: { imageStatus: "done", }, }); console.log("update was called") // <-- works just fine console.log(promise) // <-- works just fine void promise .then(() => console.log("update complete")) // <-- I only get here 1/3 times .catch((err) => console.error("update failed")) // <-- I **sometimes** get here if I refresh the page before all updates are complete } catch (err) { console.error(err) // <-- no errors are caught here }}
.middleware(...) //<-- works just fine.onUploadComplete(({ file }) => { console.log("on upload complete") // <-- works just fine try { const promise = prisma.plant.update({ // <-- returns a promise where: { imageUrl: file.url }, data: { imageStatus: "done", }, }); console.log("update was called") // <-- works just fine console.log(promise) // <-- works just fine void promise .then(() => console.log("update complete")) // <-- I only get here 1/3 times .catch((err) => console.error("update failed")) // <-- I **sometimes** get here if I refresh the page before all updates are complete } catch (err) { console.error(err) // <-- no errors are caught here }}
Additionally, I have enabled prisma query logs in production:
["query", "error", "warn"]
["query", "error", "warn"]
Any ideas on what's going on? Please let me know if there's more information I should provide.