Skip to content

Commit 3cf0b00

Browse files
adityamaruclaude
andcommitted
fix: add timeout to buildx export operation to prevent hanging
Add a 30-second timeout to the buildxHistory.export() call to prevent workflow jobs from hanging indefinitely when the buildx dial-stdio process crashes or becomes unresponsive. The build will continue with reporting even if the export fails or times out. Fixes issue where docker run export-build command would hang with "broken pipe" errors when buildx backend is unavailable. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c213746 commit 3cf0b00

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,25 @@ actionsToolkit.run(
248248
let exportRes;
249249
if (!buildError) {
250250
const buildxHistory = new BuildxHistory();
251-
exportRes = await buildxHistory.export({
252-
refs: ref ? [ref] : []
251+
252+
// Create a timeout promise that rejects after 30 seconds
253+
const exportTimeout = new Promise<never>((_, reject) => {
254+
setTimeout(() => reject(new Error('Export operation timed out after 30 seconds')), 30000);
253255
});
256+
257+
try {
258+
// Race between the export operation and the timeout
259+
exportRes = await Promise.race([
260+
buildxHistory.export({
261+
refs: ref ? [ref] : []
262+
}),
263+
exportTimeout
264+
]);
265+
} catch (exportError) {
266+
// Log the error but continue with reporting
267+
core.warning(`Build export failed: ${(exportError as Error).message}`);
268+
core.info('Continuing with build reporting without export data');
269+
}
254270
}
255271

256272
if (buildId && isBlacksmithBuilder) {

0 commit comments

Comments
 (0)