fix(release): move constants above entry point to avoid TDZ error#4398
Conversation
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.
📋 Review SummaryThis PR fixes a Temporal Dead Zone (TDZ) error in the release workflow by moving two 🔍 General Feedback
🎯 Specific FeedbackNo specific issues identified in this review. ✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
There was a problem hiding this comment.
Pull request overview
Fixes a release-time runtime failure in scripts/upload-aliyun-oss-assets.js caused by ES module temporal dead zone (TDZ) behavior when main() is invoked before MAX_UPLOAD_ATTEMPTS / INITIAL_BACKOFF_MS are initialized.
Changes:
- Move
MAX_UPLOAD_ATTEMPTSandINITIAL_BACKOFF_MSabove theisMainModule(import.meta.url)entry point so they’re initialized beforemain()can calluploadWithRetry().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — DeepSeek/deepseek-v4-pro via Qwen Code /review
wenshao
left a comment
There was a problem hiding this comment.
No review findings. Downgraded from Approve to Comment: CI failing: Test (windows-latest, Node 22.x). — DeepSeek/deepseek-v4-pro via Qwen Code /review
The subprocess-based TDZ test relies on PATH resolution of bare 'ossutil' command which doesn't work on Windows without shell: true. Since the release workflow only runs on Ubuntu, remove the test to unblock CI.
Summary
Cannot access 'MAX_UPLOAD_ATTEMPTS' before initializationduring v0.16.0 publishconst MAX_UPLOAD_ATTEMPTSandconst INITIAL_BACKOFF_MSwere declared after theisMainModule()entry point that callsmain()→uploadAssets()→uploadWithRetry(), triggering a temporal dead zone (TDZ) error in ES modulesTest plan
node --check scripts/upload-aliyun-oss-assets.jspassesnode scripts/upload-aliyun-oss-assets.js --helpruns without error