File tree 1 file changed +13
-3
lines changed
packages/tracing/src/integrations/node 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ interface PrismaClient {
38
38
$use : ( cb : PrismaMiddleware ) => void ;
39
39
}
40
40
41
+ function isValidPrismaClient ( possibleClient : unknown ) : possibleClient is PrismaClient {
42
+ return possibleClient && ! ! ( possibleClient as PrismaClient ) [ '$use' ] ;
43
+ }
44
+
41
45
/** Tracing integration for @prisma/client package */
42
46
export class Prisma implements Integration {
43
47
/**
@@ -58,8 +62,14 @@ export class Prisma implements Integration {
58
62
/**
59
63
* @inheritDoc
60
64
*/
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
+ }
63
73
}
64
74
65
75
/**
@@ -71,7 +81,7 @@ export class Prisma implements Integration {
71
81
return ;
72
82
}
73
83
74
- this . _client . $use ( ( params : PrismaMiddlewareParams , next : ( params : PrismaMiddlewareParams ) => Promise < unknown > ) => {
84
+ this . _client . $use ( ( params , next : ( params : PrismaMiddlewareParams ) => Promise < unknown > ) => {
75
85
const scope = getCurrentHub ( ) . getScope ( ) ;
76
86
const parentSpan = scope ?. getSpan ( ) ;
77
87
You can’t perform that action at this time.
0 commit comments