@ -1046,19 +1046,16 @@ Interface.prototype.trySpawn = function(cb) {
this . pause ( ) ;
setTimeout ( function ( ) {
process . stdout . write ( 'connecting...' ) ;
var client = self . client = new Client ( ) ;
client . connect ( exports . port ) ;
var client = self . client = new Client ( ) ;
var connectionAttempts = 0 ;
client . once ( 'ready' , function ( ) {
process . stdout . write ( 'ok\r\n' ) ;
client . once ( 'ready' , function ( ) {
process . stdout . write ( ' ok\r\n' ) ;
// since we did debug-brk, we're hitting a break point immediately
// continue before anything else.
client . reqContinue ( function ( ) {
if ( cb ) cb ( ) ;
} ) ;
// since we did debug-brk, we're hitting a break point immediately
// continue before anything else.
client . reqContinue ( function ( ) {
if ( cb ) cb ( ) ;
} ) ;
client . on ( 'close' , function ( ) {
@ -1067,17 +1064,37 @@ Interface.prototype.trySpawn = function(cb) {
self . killChild ( ) ;
if ( ! self . quitting ) self . term . prompt ( ) ;
} ) ;
} ) ;
client . on ( 'unhandledResponse' , function ( res ) {
console . log ( '\r\nunhandled res:' ) ;
console . log ( res ) ;
self . term . prompt ( ) ;
} ) ;
client . on ( 'unhandledResponse' , function ( res ) {
console . log ( '\r\nunhandled res:' ) ;
console . log ( res ) ;
self . term . prompt ( ) ;
} ) ;
client . on ( 'break' , function ( res ) {
self . handleBreak ( res . body ) ;
} ) ;
} , 100 ) ;
client . on ( 'break' , function ( res ) {
self . handleBreak ( res . body ) ;
} ) ;
client . on ( 'error' , connectError ) ;
function connectError ( ) {
// If it's failed to connect 4 times then don't catch the next error
if ( connectionAttempts >= 4 ) {
client . removeListener ( 'error' , connectError ) ;
}
setTimeout ( attemptConnect , 50 ) ;
}
function attemptConnect ( ) {
++ connectionAttempts ;
process . stdout . write ( '.' ) ;
client . connect ( exports . port ) ;
}
setTimeout ( function ( ) {
process . stdout . write ( 'connecting..' ) ;
attemptConnect ( ) ;
} , 50 ) ;
} ;