From 2a316f75f0415d42dd6ddc75843f212eec5b6af7 Mon Sep 17 00:00:00 2001 From: Martin Varmuza Date: Mon, 20 May 2024 07:46:25 +0200 Subject: [PATCH] chore(connect): fw-update: add error message when binary is too small --- .../connect/src/core/onCallFirmwareUpdate.ts | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/connect/src/core/onCallFirmwareUpdate.ts b/packages/connect/src/core/onCallFirmwareUpdate.ts index 3977270d8aca..94d18313109b 100644 --- a/packages/connect/src/core/onCallFirmwareUpdate.ts +++ b/packages/connect/src/core/onCallFirmwareUpdate.ts @@ -202,17 +202,27 @@ const getBinaryHelper = ( version: device.firmwareRelease.release.version, btcOnly, intermediaryVersion, - }).then(res => { - postMessage( - createUiMessage(UI.FIRMWARE_PROGRESS, { - device: device.toMessageObject(), - operation: 'downloading', - progress: 100, - }), - ); + }) + .then(res => { + console.log('res.byteLength', res.byteLength); + // suspiciously small binary. this typically happens when build does not have git lfs enabled and all + // you download here are some pointers to lfs objects + if (res.byteLength < 1000) { + throw ERRORS.TypedError('Runtime', 'Firmware binary is too small'); + } + return res; + }) + .then(res => { + postMessage( + createUiMessage(UI.FIRMWARE_PROGRESS, { + device: device.toMessageObject(), + operation: 'downloading', + progress: 100, + }), + ); - return res; - }); + return res; + }); }; const firmwareCheck = async (