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
Client extensions in interactive transactions are bound to the base client #17948
Comments
Hmm... I've downgraded to 4.9.0 and am still experiencing this issue. Perhaps it was working before for some other reason in one of my recent changes, or I've not correctly downgraded. Regardless, I do think this is an issue, but maybe it should be re-tagged as a feature request? |
Still a bug potentially, just not a regression. We'll take a look. |
Thanks, I can confirm this. I think the right thing to do is to make this work as you expected, as it would be totally unexpected that an extension could emit queries outside an interactive transaction while being explicitly used there. That said, I see anothe potential issue if we enable/fix this: it is possible that an extension would want to also emit a batch transaction (call For reference, |
Is there a timeline for when a fix is planned? |
No, we never commit to timelines publicly because plans change. |
Are there any other workaround to mitigate this for the time-being? Also running into the same issue. |
I'm experiencing the same issue! |
Especially frustrating in our integration tests, where we have await prisma.$transaction(tx => {
tx.myModel.create({
data: {}
})
return tx.myModel.myExtension()
}) The call to |
I'm also suffering from this issue: It's blocking me from migrating to use client extensions instead of generating code for custom db repositories. |
This is fixed in #19565 and will be available in the next prisma release. |
Nice! Will try it out tomorrow! 🎉 |
Tried it and it seems to have fixed the tests I written for my client extensions regarding transactions (which was failing previously) 🎉 However a little heads up, it seems as if it broke some other tests, and the error I'm getting: error TypeError: 'get' on proxy: property '_extensions' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '#<et>' but got '#<et>')
at ru (/node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:162:11145)
at a (/node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:177:10309)
at /node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:177:10445
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at /node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:177:10425
at Proxy.runInChildSpan (/node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:174:1343)
at Proxy.<anonymous> (/node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:178:848)
at Proxy._request (/node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:177:10348)
at Proxy.<anonymous> (/node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:178:848)
at Proxy.$queryRawInternal (/node_modules/.pnpm/@prisma+client@4.16.0-dev.17_prisma@4.16.0-dev.17/node_modules/@prisma/client/runtime/library.js:177:7988) Will see if I can come up with a minimal reproduction for the issue |
describe("success", () => {
test("breaks if using $queryRawUnsafe", async () => {
const result = await prisma.$queryRawUnsafe(
`SELECT * FROM machine_user;`
);
expect(result).toEqual([]);
});
test("breaks if using $queryRaw", async () => {
const result =
await prisma.$queryRaw<unknown>`SELECT * FROM machine_user;`;
expect(result).toEqual([]);
});
});
describe("error", () => {
test("breaks if using $queryRawUnsafe", async () => {
const result = await prisma.$transaction(async (tx) => {
return tx.$queryRawUnsafe(`SELECT * FROM machine_user;`);
});
expect(result).toEqual([]);
});
test("breaks if using $queryRaw", async () => {
const result = await prisma.$transaction(async (tx) => {
return tx.$queryRaw<unknown>`SELECT * FROM machine_user;`;
});
expect(result).toEqual([]);
});
}); Both the "error"-tests fails with the following error:
FYI @Jolg42 |
Thanks @marcus13371337! If you can create a new issue, that would be great 🙌🏼 |
Issue created here |
Bug description
Extensions to the Prisma client have
this
bound to the base client as opposed to the transaction. I was not experiencing this problem in 4.9.0.How to reproduce
this
in some way.this
will be the base Prisma client instead of the transaction client.Expected behavior
When client extensions are used within a transaction,
this
should be bound to the transaction client instead of the original Prisma client.Prisma information
Schema does not appear to be relevant.
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: