MCPcopy
hub / github.com/prisma/prisma / _callback

Function _callback

packages/client/src/runtime/core/request/createPrismaPromise.ts:30–44  ·  view source on GitHub ↗
(callbackTransaction = transaction)

Source from the content-addressed store, hash-verified

28 ): PrismaPromise<unknown, TSpec> {
29 let promise: PrismaPromise<unknown> | undefined
30 const _callback = (callbackTransaction = transaction): PrismaPromise<unknown> => {
31 try {
32 // promises cannot be triggered twice after resolving
33 if (callbackTransaction === undefined || callbackTransaction?.kind === 'itx') {
34 return (promise ??= valueToPromise(callback(callbackTransaction)))
35 }
36
37 // but for batch tx we can trigger them again & again
38 return valueToPromise(callback(callbackTransaction))
39 } catch (error) {
40 // if the callback throws, then we reject the promise
41 // and that is because exceptions are not always async
42 return Promise.reject(error) as PrismaPromise<unknown>
43 }
44 }
45
46 return {
47 get spec() {

Callers 4

thenFunction · 0.85
catchFunction · 0.85
finallyFunction · 0.85
requestTransactionFunction · 0.85

Calls 1

valueToPromiseFunction · 0.85

Tested by

no test coverage detected