11import React , { useCallback , useState } from 'react' ;
22
33/**
4- * Updates every container with `updateAvailable && !pinned`, sequentially :
5- * each one is started and fully awaited (start + SSE stream to completion,
6- * handled by `runUpdate`) before the next one begins. A failure on one
7- * container does not stop the batch — `runUpdate` is expected to resolve
8- * (not reject) even on failure, so this loop always continues .
4+ * Updates every container with `updateAvailable && !pinned`, all at once :
5+ * each is started immediately and its own SSE stream runs concurrently
6+ * ( handled by `runUpdate`). A failure on one container does not affect the
7+ * others — `runUpdate` resolves (not rejects) even on failure, and
8+ * `Promise.allSettled` waits for them all regardless .
99 *
1010 * Disabled when there are no eligible targets or any update is in flight.
1111 */
@@ -15,13 +15,8 @@ export default function UpdateAllButton({ targets, runUpdate, disabled }) {
1515 const handleClick = useCallback ( async ( ) => {
1616 if ( running || disabled || targets . length === 0 ) return ;
1717 setRunning ( true ) ;
18- for ( const name of targets ) {
19- try {
20- await runUpdate ( name ) ;
21- } catch {
22- // Swallow — a failure for one container must not stop the batch.
23- }
24- }
18+ // Fire them all immediately, then wait for the whole batch to settle.
19+ await Promise . allSettled ( targets . map ( ( name ) => runUpdate ( name ) ) ) ;
2520 setRunning ( false ) ;
2621 } , [ running , disabled , targets , runUpdate ] ) ;
2722
0 commit comments