File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
packages/tracing/src/integrations/node Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ interface PrismaClient {
3838 $use : ( cb : PrismaMiddleware ) => void ;
3939}
4040
41+ function isValidPrismaClient ( possibleClient : unknown ) : possibleClient is PrismaClient {
42+ return possibleClient && ! ! ( possibleClient as PrismaClient ) [ '$use' ] ;
43+ }
44+
4145/** Tracing integration for @prisma/client package */
4246export class Prisma implements Integration {
4347 /**
@@ -58,8 +62,14 @@ export class Prisma implements Integration {
5862 /**
5963 * @inheritDoc
6064 */
61- public constructor ( options : { client ?: PrismaClient } = { } ) {
62- this . _client = options . client ;
65+ public constructor ( options : { client ?: unknown } = { } ) {
66+ if ( isValidPrismaClient ( options . client ) ) {
67+ this . _client = options . client ;
68+ } else {
69+ logger . warn (
70+ `Unsupported Prisma client provided to PrismaIntegration. Provided client: ${ JSON . stringify ( options . client ) } ` ,
71+ ) ;
72+ }
6373 }
6474
6575 /**
@@ -71,7 +81,7 @@ export class Prisma implements Integration {
7181 return ;
7282 }
7383
74- this . _client . $use ( ( params : PrismaMiddlewareParams , next : ( params : PrismaMiddlewareParams ) => Promise < unknown > ) => {
84+ this . _client . $use ( ( params , next : ( params : PrismaMiddlewareParams ) => Promise < unknown > ) => {
7585 const scope = getCurrentHub ( ) . getScope ( ) ;
7686 const parentSpan = scope ?. getSpan ( ) ;
7787
You can’t perform that action at this time.
0 commit comments