@@ -180,10 +180,56 @@ function chromeSharedLibOutcome(
180180 } ;
181181}
182182
183+ function chromeLaunchFailureDetails ( error : unknown ) : string {
184+ if ( typeof error !== "object" || error === null ) return "" ;
185+ const status = "status" in error ? error . status : undefined ;
186+ const signal = "signal" in error ? error . signal : undefined ;
187+ const code = "code" in error ? error . code : undefined ;
188+ return [
189+ typeof status === "number" ? `exit code ${ status } ` : "" ,
190+ typeof signal === "string" ? `signal ${ signal } ` : "" ,
191+ typeof code === "string" ? code : "" ,
192+ ]
193+ . filter ( Boolean )
194+ . join ( ", " ) ;
195+ }
196+
197+ function chromeLaunchOutcome (
198+ executablePath : string ,
199+ found : EnvironmentCheckOutcome ,
200+ ) : EnvironmentCheckOutcome {
201+ const libraries = chromeSharedLibOutcome ( executablePath , found ) ;
202+ if ( ! libraries . ok ) return libraries ;
203+ try {
204+ execFileSync ( executablePath , [ "--version" ] , {
205+ encoding : "utf-8" ,
206+ stdio : [ "ignore" , "pipe" , "pipe" ] ,
207+ timeout : 5000 ,
208+ killSignal : "SIGKILL" ,
209+ maxBuffer : 64 * 1024 ,
210+ windowsHide : true ,
211+ } ) ;
212+ return found ;
213+ } catch ( error ) {
214+ const details = chromeLaunchFailureDetails ( error ) ;
215+ return {
216+ name : "Chrome" ,
217+ ok : false ,
218+ level : "error" ,
219+ title : "Chrome cannot start" ,
220+ detail : `Failed to run "${ executablePath } " --version${ details ? ` (${ details } )` : "" } .` ,
221+ hint :
222+ "Select a working Chrome/Chromium binary for this OS and architecture with " +
223+ "HYPERFRAMES_BROWSER_PATH, or reinstall with: npx hyperframes browser ensure --force" ,
224+ path : executablePath ,
225+ } ;
226+ }
227+ }
228+
183229async function checkChrome ( browserPath ?: string ) : Promise < EnvironmentCheckOutcome > {
184230 if ( browserPath ) {
185231 if ( existsSync ( browserPath ) ) {
186- return chromeSharedLibOutcome ( browserPath , {
232+ return chromeLaunchOutcome ( browserPath , {
187233 name : "Chrome" ,
188234 ok : true ,
189235 level : "ok" ,
@@ -213,7 +259,7 @@ async function checkChrome(browserPath?: string): Promise<EnvironmentCheckOutcom
213259 info = undefined ;
214260 }
215261 if ( info ) {
216- return chromeSharedLibOutcome ( info . executablePath , {
262+ return chromeLaunchOutcome ( info . executablePath , {
217263 name : "Chrome" ,
218264 ok : true ,
219265 level : "ok" ,
0 commit comments