From f1c20c97c9c2558a5c6a45d2b342fa4f2b76f9b9 Mon Sep 17 00:00:00 2001 From: Yaroslav Petrenko Date: Fri, 19 Jan 2024 14:57:14 +0200 Subject: [PATCH] fix: Do not create a Proxy with null as a target --- lib/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index d82b27b..1096775 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -320,7 +320,9 @@ const registerVerboseListeners = ( const clientId = socket.client.id; const createProxy = (obj: any) => { - if (typeof obj !== "object") { + // typeof null is object, but null can't be used as a target for Proxy + // Ref:https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null + if (typeof obj !== "object" || obj === null) { return obj; } return new Proxy(obj, {