-
Notifications
You must be signed in to change notification settings - Fork 16
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
If an error occurs during transaction, processing cannot continue #141
Comments
@hokaccha Thanks for your reporting. I reproduced this message. And I can suppress the /* user.test.ts */
test("ensureUser", async () => {
const data = { id: 1, name: "foo" };
// succeed
expect(await ensureUser(jestPrisma.client, data)).toBe(true);
try {
await jestPrisma.client.$transaction(async () => {
// succeed
expect(await ensureUser(jestPrisma.client, data)).toBe(true);
throw new Error();
});
} catch {}
expect(await jestPrisma.client.user.count()).toBe(1);
}); /* jest.config.mjs */
export default {
testEnvironment: "@quramy/jest-prisma-node/environment",
testEnvironmentOptions: {
enableExperimentalRollbackInTransaction: true, // Enable nested $transaction in test code
},
}; Here is full example: https://github.com/Quramy/jest-prisma-repro-141/pull/1/files . |
I see, it seems like this problem can be solved this way. Thank you. |
As far as I'm concerned, it's okay to close this issue, but I'll leave the decision up to you 🙏 |
Thanks. I'll write about this problem and the workaround to README's tips section. |
When handling a unique constraint error, such as the following, executing a query after a unique constraint error occurs will result in an error.
I suspect this is due to PostgresSQL's limitation that if an error occurs during a transaction, subsequent queries cannot be issued.
The text was updated successfully, but these errors were encountered: