Merge pull request #128 from useblacksmith/fix/export-timeout

fix: add timeout to buildx export operation
This commit is contained in:
Aditya Maru 2025-08-05 07:08:35 -04:00 committed by GitHub
commit 4af38cd115
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 4 deletions

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -248,9 +248,30 @@ actionsToolkit.run(
let exportRes;
if (!buildError) {
const buildxHistory = new BuildxHistory();
exportRes = await buildxHistory.export({
refs: ref ? [ref] : []
// Create a timeout promise that rejects after 30 seconds
let timeoutId: NodeJS.Timeout | undefined;
const exportTimeout = new Promise<never>((_, reject) => {
timeoutId = setTimeout(() => reject(new Error('Export operation timed out after 30 seconds')), 30000);
});
try {
// Race between the export operation and the timeout
exportRes = await Promise.race([
buildxHistory.export({
refs: ref ? [ref] : []
}),
exportTimeout
]);
// Clear the timeout if export completes successfully
if (timeoutId) clearTimeout(timeoutId);
} catch (exportError) {
// Clear the timeout on error as well
if (timeoutId) clearTimeout(timeoutId);
// Log the error but continue with reporting
core.warning(`Build export failed: ${(exportError as Error).message}`);
core.info('Continuing with build reporting without export data');
}
}
if (buildId && isBlacksmithBuilder) {