@@ -225,7 +225,10 @@ describe("plugins Docker assertions", () => {
225225 expect ( script ) . toContain ( "run(controller.signal, timeoutPromise)" ) ;
226226 expect (
227227 script . match ( / r e a d B o u n d e d R e s p o n s e T e x t \( [ \s \S ] * ?l i m i t s \. b o d y M a x B y t e s , \n \s + t i m e o u t P r o m i s e , / gu) ,
228- ) . toHaveLength ( 2 ) ;
228+ ) . toHaveLength ( 1 ) ;
229+ expect ( script ) . toMatch (
230+ / w i t h T i m e o u t \( \s * ` C l a w H u b p a c k a g e p r e f l i g h t f o r \$ \{ p a c k a g e N a m e \} ` , \s * l i m i t s \. t i m e o u t M s , \s * a s y n c \( s i g n a l , t i m e o u t P r o m i s e \) = > \{ [ \s \S ] * ?f e t c h \( [ \s \S ] * ?r e a d B o u n d e d R e s p o n s e T e x t \( [ \s \S ] * ?J S O N \. p a r s e \( r a w D e t a i l \) / u,
231+ ) ;
229232 } ) ;
230233
231234 it ( "keeps sweep artifact paths aligned with the assertion scratch root" , ( ) => {
@@ -1444,8 +1447,53 @@ test -d "$OPENCLAW_PLUGINS_TMP_DIR"
14441447
14451448 expect ( result . status ) . not . toBe ( 0 ) ;
14461449 expect ( result . stderr ) . toContain (
1447- "ClawHub package preflight response for @openclaw/kitchen-sink timed out after 75ms" ,
1450+ "ClawHub package preflight for @openclaw/kitchen-sink timed out after 75ms" ,
1451+ ) ;
1452+ } finally {
1453+ await new Promise < void > ( ( resolve ) => {
1454+ server . close ( ( ) => resolve ( ) ) ;
1455+ } ) ;
1456+ }
1457+ } ) ;
1458+
1459+ it ( "keeps ClawHub preflight wall time within one shared timeout budget" , async ( ) => {
1460+ const timeoutMs = 300 ;
1461+ const headerDelayMs = 250 ;
1462+ // Shared budget finishes near spawn + timeoutMs. Stacked per-phase budgets need at
1463+ // least spawn + headerDelayMs + timeoutMs, so they cannot pass this ceiling.
1464+ const maxSharedElapsedMs = timeoutMs + 240 ;
1465+ const server = createServer ( ( _request , response ) => {
1466+ const timer = setTimeout ( ( ) => {
1467+ response . writeHead ( 200 , { "content-type" : "application/json" } ) ;
1468+ response . flushHeaders ( ) ;
1469+ response . write ( "{" ) ;
1470+ } , headerDelayMs ) ;
1471+ timer . unref ?.( ) ;
1472+ } ) ;
1473+ await new Promise < void > ( ( resolve ) => {
1474+ server . listen ( 0 , "127.0.0.1" , resolve ) ;
1475+ } ) ;
1476+
1477+ try {
1478+ const address = server . address ( ) ;
1479+ if ( ! address || typeof address === "string" ) {
1480+ throw new Error ( "expected TCP server address" ) ;
1481+ }
1482+ const started = Date . now ( ) ;
1483+ const result = await runAssertionAsync ( [ "clawhub-preflight" ] , {
1484+ CLAWHUB_PLUGIN_ID : "openclaw-kitchen-sink-fixture" ,
1485+ CLAWHUB_PLUGIN_SPEC : "clawhub:@openclaw/kitchen-sink" ,
1486+ OPENCLAW_CLAWHUB_URL : `http://127.0.0.1:${ address . port } ` ,
1487+ OPENCLAW_PLUGINS_E2E_CLAWHUB_PREFLIGHT_TIMEOUT_MS : String ( timeoutMs ) ,
1488+ } ) ;
1489+ const elapsedMs = Date . now ( ) - started ;
1490+
1491+ expect ( result . status ) . not . toBe ( 0 ) ;
1492+ expect ( result . stderr ) . toContain (
1493+ `ClawHub package preflight for @openclaw/kitchen-sink timed out after ${ timeoutMs } ms` ,
14481494 ) ;
1495+ expect ( maxSharedElapsedMs ) . toBeLessThan ( headerDelayMs + timeoutMs ) ;
1496+ expect ( elapsedMs ) . toBeLessThan ( maxSharedElapsedMs ) ;
14491497 } finally {
14501498 await new Promise < void > ( ( resolve ) => {
14511499 server . close ( ( ) => resolve ( ) ) ;
0 commit comments