Skip to content

Commit

Permalink
Guard against undefined.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan authored Dec 5, 2024
1 parent d3bf605 commit bd89bcc
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,15 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
'pg',
SUPPORTED_PG_VERSIONS,
(module: any) => {
this._patchPgClient(module.Client);
const moduleExports = extractModuleExports(module);

this._patchPgClient(moduleExports.Client);
return module;
},
(module: any) => {
this._unpatchPgClient(module.Client);
const moduleExports = extractModuleExports(module);

this._unpatchPgClient(moduleExports.Client);
return module;
},
[modulePgClient, modulePgNativeClient]
Expand Down Expand Up @@ -187,6 +191,10 @@ export class PgInstrumentation extends InstrumentationBase<PgInstrumentationConf
}

private _patchPgClient(module: any) {
if (!module) {
return;
}

const moduleExports = extractModuleExports(module);

if (isWrapped(moduleExports.prototype.query)) {
Expand Down

0 comments on commit bd89bcc

Please sign in to comment.