File tree 1 file changed +13
-2
lines changed
packages/vite/src/node/server
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export function openBrowser(
34
34
const browserArgs = process . env . BROWSER_ARGS
35
35
? process . env . BROWSER_ARGS . split ( ' ' )
36
36
: [ ]
37
- startBrowserProcess ( browser , browserArgs , url )
37
+ startBrowserProcess ( browser , browserArgs , url , logger )
38
38
}
39
39
}
40
40
@@ -72,6 +72,7 @@ async function startBrowserProcess(
72
72
browser : string | undefined ,
73
73
browserArgs : string [ ] ,
74
74
url : string ,
75
+ logger : Logger ,
75
76
) {
76
77
// If we're on OS X, the user hasn't specifically
77
78
// requested a different browser, we can try opening
@@ -122,7 +123,17 @@ async function startBrowserProcess(
122
123
const options : open . Options = browser
123
124
? { app : { name : browser , arguments : browserArgs } }
124
125
: { }
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
+
126
137
return true
127
138
} catch ( err ) {
128
139
return false
You can’t perform that action at this time.
0 commit comments