From a41afc465d2906972adb1a3f82dc26d575fbb64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=93=E8=89=AF?= <1204183885@qq.com> Date: Sat, 23 May 2026 22:21:33 +0800 Subject: [PATCH] fix(release): move constants above entry point to avoid TDZ error (#4398) MAX_UPLOAD_ATTEMPTS and INITIAL_BACKOFF_MS were declared after the isMainModule() guard that calls main(). In ES modules, const bindings are not initialized until the declaration is reached, so the runtime threw "Cannot access 'MAX_UPLOAD_ATTEMPTS' before initialization" during the Release workflow. --- scripts/upload-aliyun-oss-assets.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upload-aliyun-oss-assets.js b/scripts/upload-aliyun-oss-assets.js index 7013c677ec..8449b17881 100644 --- a/scripts/upload-aliyun-oss-assets.js +++ b/scripts/upload-aliyun-oss-assets.js @@ -10,6 +10,9 @@ import path from 'node:path'; import { spawnSync } from 'node:child_process'; import { fail, isMainModule, readOptionValue } from './release-script-utils.js'; +const MAX_UPLOAD_ATTEMPTS = 3; +const INITIAL_BACKOFF_MS = 2000; + if (isMainModule(import.meta.url)) { try { main(process.argv.slice(2)); @@ -96,9 +99,6 @@ function parseUploadArgs(argv) { return args; } -const MAX_UPLOAD_ATTEMPTS = 3; -const INITIAL_BACKOFF_MS = 2000; - function uploadAssets( { assets, bucket, config, prefix }, { ossutilCommand = 'ossutil', ossutilCommandArgs = [] } = {},