diff --git a/plugins/node/instrumentation-fs/src/instrumentation.ts b/plugins/node/instrumentation-fs/src/instrumentation.ts index 53ec3fed1e..6bd778da83 100644 --- a/plugins/node/instrumentation-fs/src/instrumentation.ts +++ b/plugins/node/instrumentation-fs/src/instrumentation.ts @@ -64,12 +64,12 @@ export default class FsInstrumentation extends InstrumentationBase { ); } for (const fName of CALLBACK_FUNCTIONS) { + if (isWrapped(fs[fName])) { + this._unwrap(fs, fName); + } if (fName === 'exists') { // handling separately because of the inconsistent cb style: // `exists` doesn't have error as the first argument, but the result - if (isWrapped(fs[fName])) { - this._unwrap(fs, fName); - } this._wrap( fs, fName, @@ -77,9 +77,6 @@ export default class FsInstrumentation extends InstrumentationBase { ); continue; } - if (isWrapped(fs[fName])) { - this._unwrap(fs, fName); - } this._wrap( fs, fName,