File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/vite/src/node/server Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export function openBrowser(
3434 const browserArgs = process . env . BROWSER_ARGS
3535 ? process . env . BROWSER_ARGS . split ( ' ' )
3636 : [ ]
37- startBrowserProcess ( browser , browserArgs , url )
37+ startBrowserProcess ( browser , browserArgs , url , logger )
3838 }
3939}
4040
@@ -72,6 +72,7 @@ async function startBrowserProcess(
7272 browser : string | undefined ,
7373 browserArgs : string [ ] ,
7474 url : string ,
75+ logger : Logger ,
7576) {
7677 // If we're on OS X, the user hasn't specifically
7778 // requested a different browser, we can try opening
@@ -122,7 +123,17 @@ async function startBrowserProcess(
122123 const options : open . Options = browser
123124 ? { app : { name : browser , arguments : browserArgs } }
124125 : { }
125- open ( url , options ) . catch ( ( ) => { } ) // Prevent `unhandledRejection` error.
126+
127+ new Promise ( ( _ , reject ) => {
128+ open ( url , options )
129+ . then ( ( subprocess ) => {
130+ subprocess . on ( 'error' , reject )
131+ } )
132+ . catch ( reject )
133+ } ) . catch ( ( err ) => {
134+ logger . error ( err . stack || err . message )
135+ } )
136+
126137 return true
127138 } catch ( err ) {
128139 return false
You can’t perform that action at this time.
0 commit comments