test: the browser tests try Chrome's first connection again while it starts (CI run 416)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 8m27s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m18s

Chrome writes DevToolsActivePort a moment before it accepts connections;
run 416 connected in that gap (ECONNREFUSED, then "DevTools listening") and
failed before any page loaded. Both browser tests now retry a refused first
connection for up to ten seconds; any other error still fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 15:12:22 -03:00
parent cc460c6e0c
commit dea8036b73
2 changed files with 17 additions and 2 deletions

View File

@@ -104,7 +104,13 @@ async function screenshot(name){
try{
let port;
await waitFor(async()=>{try{port=Number((await readFile(profile+'/DevToolsActivePort','utf8')).split('\n')[0]);return true;}catch{return false;}},'Chrome startup');
const tab=await(await fetch(`http://127.0.0.1:${port}/json/new?about:blank`,{method:'PUT'})).json();
// Chrome writes DevToolsActivePort a moment before it accepts connections
// (CI run 416): a refused connection is tried again for a few seconds.
let tab;
for(let attempt=0;!tab;attempt++){
try{tab=await(await fetch(`http://127.0.0.1:${port}/json/new?about:blank`,{method:'PUT'})).json();}
catch(error){if(attempt>=50||error?.cause?.code!=='ECONNREFUSED')throw error;await pause(200);}
}
ws=new WebSocket(tab.webSocketDebuggerUrl);
await new Promise((r,j)=>{ws.onopen=r;ws.onerror=j;});
ws.onmessage=event=>{