This repository was archived by the owner on Apr 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ module.exports = {
7070
7171 // These configuration options are for internal experimentation only.
7272 internal : {
73- registerDelayOnFetcherErrorSec : 300 // 5 minutes.
73+ registerDelayOnFetcherErrorSec : 300 , // 5 minutes.
74+ maxRegistrationRetryDelay : 40
7475 }
7576 }
7677} ;
Original file line number Diff line number Diff line change @@ -142,8 +142,8 @@ Debuglet.prototype.scheduleRegistration_ = function(seconds) {
142142
143143 function onError ( err ) {
144144 that . logger_ . error ( 'Failed to re-register debuggee: ' + err ) ;
145- that . logger_ . error ( 'Disabling gcloud debuglet' ) ;
146- that . stop ( ) ; // fatal error
145+ that . scheduleRegistration_ ( Math . min ( ( seconds + 1 ) * 2 ,
146+ that . config_ . internal . maxRegistrationRetryDelay ) ) ;
147147 }
148148
149149 setTimeout ( function ( ) {
Original file line number Diff line number Diff line change @@ -92,6 +92,31 @@ describe(__filename, function(){
9292 debuglet . start ( ) ;
9393 } ) ;
9494
95+ it ( 'should retry on failed registration' , function ( done ) {
96+ this . timeout ( 10000 ) ;
97+ process . env . GCLOUD_PROJECT = '11020304f2934' ;
98+
99+ var scope = nock ( API )
100+ . post ( REGISTER_PATH )
101+ . reply ( 404 )
102+ . post ( REGISTER_PATH )
103+ . reply ( 509 )
104+ . post ( REGISTER_PATH )
105+ . reply ( 200 , {
106+ debuggee : {
107+ id : DEBUGGEE_ID
108+ }
109+ } ) ;
110+
111+ debuglet . once ( 'registered' , function ( id ) {
112+ assert ( id === DEBUGGEE_ID ) ;
113+ scope . done ( ) ;
114+ done ( ) ;
115+ } ) ;
116+
117+ debuglet . start ( ) ;
118+ } ) ;
119+
95120 it ( 'should error if a package.json doesn\'t exist' ) ;
96121
97122 it ( 'should register successfully otherwise' , function ( done ) {
You can’t perform that action at this time.
0 commit comments