From f9b314354b2ae36439cf3beb21ea20bc9d0b53bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=9C=E5=AD=90?= Date: Fri, 15 May 2026 10:14:36 +0800 Subject: [PATCH] fix: check null before typeof in isJSONSerializable (#571) typeof null returns 'object', not null, so t === null is always false (dead code). When value is null, it falls through to the object branch and crashes on value.buffer access. Move null check to use value === null before typeof comparison. Fixes #571 --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index a773431b..eca6b351 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -19,7 +19,7 @@ export function isJSONSerializable(value: any): boolean { return false; } const t = typeof value; - if (t === "string" || t === "number" || t === "boolean" || t === null) { + if (value === null || t === "string" || t === "number" || t === "boolean") { return true; } if (t !== "object") {