From cb628956f7d0c01bd9cbd5c351df90a1448121a1 Mon Sep 17 00:00:00 2001 From: Assaf Vayner Date: Thu, 14 May 2026 09:27:56 -0700 Subject: [PATCH] fix(napi): omit Option fields from downloadFile when unset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit napi-rs 2.16 rejects explicit `null` for `Option` fields on Linux — only undefined (an omitted property) is accepted. The previous `authToken: token` form passed `null` when HF_TOKEN was unset, tripping the type guard. Spread the field conditionally so it's only present when truthy. Same treatment for sha256, which is null when X-Linked-Etag is absent. --- examples/xet_pkg_napi/smoke.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/xet_pkg_napi/smoke.mjs b/examples/xet_pkg_napi/smoke.mjs index e6a0577a..d94bf85d 100644 --- a/examples/xet_pkg_napi/smoke.mjs +++ b/examples/xet_pkg_napi/smoke.mjs @@ -89,10 +89,10 @@ console.log(`\nDownloading -> ${destPath}`); const t0 = Date.now(); const result = addon.downloadFile({ tokenRefreshUrl, - authToken: token, + ...(token ? { authToken: token } : {}), xetHash, fileSize, - sha256, + ...(sha256 ? { sha256 } : {}), destPath, }); const elapsedSec = (Date.now() - t0) / 1000;