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.
This commit is contained in:
易良 2026-05-23 22:21:33 +08:00 committed by GitHub
parent e43852f769
commit a41afc465d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 = [] } = {},