diff --git a/packages/mini-fix/src/index.ts b/packages/mini-fix/src/index.ts index 891a6904..d19edc54 100644 --- a/packages/mini-fix/src/index.ts +++ b/packages/mini-fix/src/index.ts @@ -103,11 +103,13 @@ function smoothOutParams() { const filterFunctions = (obj: any, isApp = false) => { try { - Object.keys(obj) - .filter((prop) => typeof obj[prop] === 'function') - .forEach((methodName) => { - wrapMethod(obj, methodName, isApp) - }) + if (obj) { + Object.keys(obj) + .filter((prop) => typeof obj[prop] === 'function') + .forEach((methodName) => { + wrapMethod(obj, methodName, isApp) + }) + } } catch (e) { console.info('antmjs filterFunctions error', e) } diff --git a/packages/trace/src/index.ts b/packages/trace/src/index.ts index 0333a215..fb3b2ad3 100644 --- a/packages/trace/src/index.ts +++ b/packages/trace/src/index.ts @@ -461,11 +461,13 @@ const wrapMethod = function (target: any, methodName: string, isApp = false) { */ const filterFunctions = (obj: any, isApp = false) => { try { - Object.keys(obj) - .filter((prop) => typeof obj[prop] === 'function') - .forEach((methodName) => { - wrapMethod(obj, methodName, isApp) - }) + if (obj) { + Object.keys(obj) + .filter((prop) => typeof obj[prop] === 'function') + .forEach((methodName) => { + wrapMethod(obj, methodName, isApp) + }) + } } catch (e) { console.info('trace filterFunctions error', e) }