fix(release-upload): clear progress timer on upload completion/error and add periodic upload progress reporting

This commit is contained in:
2026-01-09 18:19:30 +00:00
parent 98398e962f
commit 21f7a44a53
2 changed files with 28 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ async function uploadFile(filepath: string): Promise<void> {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => {
clearInterval(progressInterval);
console.log(data);
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
console.log(`${filename} uploaded successfully`);
@@ -57,13 +58,30 @@ async function uploadFile(filepath: string): Promise<void> {
});
});
req.on('error', reject);
req.on('error', (err) => {
clearInterval(progressInterval);
reject(err);
});
// Track upload progress
let bytesWritten = header.length;
const progressInterval = setInterval(() => {
const percent = Math.round((bytesWritten / contentLength) * 100);
console.log(` ${filename}: ${percent}% (${Math.round(bytesWritten / 1024 / 1024)}MB / ${Math.round(contentLength / 1024 / 1024)}MB)`);
}, 10000);
// Stream: write header, pipe file, write footer
req.write(header);
const stream = fs.createReadStream(filepath);
stream.on('error', reject);
stream.on('data', (chunk) => {
bytesWritten += chunk.length;
});
stream.on('error', (err) => {
clearInterval(progressInterval);
reject(err);
});
stream.on('end', () => {
bytesWritten += footer.length;
req.write(footer);
req.end();
});

View File

@@ -1,5 +1,13 @@
# Changelog
## 2026-01-09 - 0.4.1 - fix(release-upload)
clear progress timer on upload completion/error and add periodic upload progress reporting
- Clear the progress interval on response end and on stream/error to avoid leaking timers.
- Track bytesWritten (header + stream chunks + footer) to compute accurate progress percentages.
- Log upload progress (percent and MB) every 10 seconds for visibility.
- Handle stream errors by clearing the progress timer and rejecting with the error.
## 2026-01-09 - 0.4.0 - feat(displays)
add display detection and management (sway) with daemon APIs and UI controls