diff --git a/packages/client/src/runtime/core/extensions/$extends.ts b/packages/client/src/runtime/core/extensions/$extends.ts index 92fbc937f421..585eaa2af1dd 100644 --- a/packages/client/src/runtime/core/extensions/$extends.ts +++ b/packages/client/src/runtime/core/extensions/$extends.ts @@ -94,7 +94,7 @@ export function $extends(this: Client, extension: Args | ((client: Client) => Cl const oldClient = unapplyModelsAndClientExtensions(this) const newClient = Object.create(oldClient, { _extensions: { - get: () => this._extensions.append(extension), + value: this._extensions.append(extension), }, }) diff --git a/packages/client/tests/functional/extensions/enabled/extends.ts b/packages/client/tests/functional/extensions/enabled/extends.ts index 54878d3fae02..b96b84cbd35b 100644 --- a/packages/client/tests/functional/extensions/enabled/extends.ts +++ b/packages/client/tests/functional/extensions/enabled/extends.ts @@ -14,4 +14,10 @@ testMatrix.setupTestSuite(() => { expectTypeOf(xprisma).not.toHaveProperty('$use') expect(await xprisma.user.findMany()).toEqual([]) }) + + test('does not recompute extensions property on every access', () => { + const xprisma = prisma.$extends({}) + + expect((xprisma as any)._extensions).toBe((xprisma as any)._extensions) + }) })