File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
packages/network-debugger/src/fork Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -103,20 +103,30 @@ export class DevtoolServer {
103103 wait : true
104104 } )
105105
106- if ( process . platform !== 'darwin' ) {
106+ cdpConnect: if ( process . platform !== 'darwin' ) {
107107 const json = await new Promise < { webSocketDebuggerUrl : string ; id : string } [ ] > (
108108 ( resolve ) => {
109+ let count = 0
109110 let stop = setInterval ( async ( ) => {
111+ if ( count > 5 ) {
112+ clearInterval ( stop )
113+ resolve ( [ ] )
114+ }
110115 try {
116+ count ++
111117 resolve ( ( await fetch ( `http://localhost:${ REMOTE_DEBUGGER_PORT } /json` ) ) . json ( ) )
112118 clearInterval ( stop )
113119 } catch {
114- log ( 'waiting for chrome to open' )
120+ // ignore
115121 }
116122 } , 500 )
117123 }
118124 )
119- const { id, webSocketDebuggerUrl } = json [ 0 ]
125+ const [ data ] = json
126+ if ( ! data ) {
127+ break cdpConnect
128+ }
129+ const { id, webSocketDebuggerUrl } = data
120130 const debuggerWs = new WebSocket ( webSocketDebuggerUrl )
121131
122132 debuggerWs . on ( 'open' , ( ) => {
You can’t perform that action at this time.
0 commit comments