Author: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat Sep 13 05:45:41 2025 +0100 builder: Fix race condition causing jobs to stall The 'finished' status for a task step was being sent with the second-to-last log message instead of the very last one. This was because the check for sending the status was for when one item remained in the log queue. Due to the LIFO processing of logs, this was not the final log message to be sent. This created a race condition where the server would receive the 'finished' status and issue the next task step while the builder was still sending the final log for the previous step. This could put the builder into a confused state and cause the job to stall. The fix is to change the condition to send the 'finished' status only with the actual last log message, which is when the log queue becomes empty after processing the current chunk. diff --git a/src/builder/b-comms.c b/src/builder/b-comms.c index 10c04f5..edce574 100644 --- a/src/builder/b-comms.c +++ b/src/builder/b-comms.c @@ -347,10 +347,7 @@ send_logs: ns->task->uuid, (unsigned long long)lws_now_usecs(), chunk->stdfd, (int)chunk->len); - if (ns->finished_when_logs_drained && ns->chunk_cache.count == 1) - /* - * Let the last guy report the finished state - */ + if (ns->finished_when_logs_drained && !ns->chunk_cache.count) n += lws_snprintf((char *)p + n, lws_ptr_diff_size_t(end, p) - (unsigned int)n, "\"finished\":%d,", ns->retcode);