From 905851eae75d8866dda7584743b5191f8c8c1bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=B0=91?= Date: Fri, 10 Nov 2023 21:23:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dundefined=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/mini-fix/src/index.ts | 12 +++++++----- packages/trace/src/index.ts | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) 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) }