File tree 2 files changed +20
-1
lines changed 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,8 @@ function forkLambda(
231
231
invoke ( event , context , callback ) {
232
232
if ( idle_timer ) {
233
233
clearTimeout ( idle_timer ) ;
234
+ idle_timer = null ;
234
235
}
235
- idle_timer = setTimeout ( kill , max_idle ) ;
236
236
const i = ++ id ;
237
237
const ms_timeout = timeout * 1000 ;
238
238
if ( ! inspect_lambda ) {
@@ -247,6 +247,8 @@ function forkLambda(
247
247
clearTimeout ( timeout_timer ) ;
248
248
if ( graceful_shutdown ) {
249
249
kill ( ) ;
250
+ } else if ( ! err ) {
251
+ idle_timer = setTimeout ( kill , max_idle ) ;
250
252
}
251
253
callback ( err , value ) ;
252
254
} ;
Original file line number Diff line number Diff line change @@ -476,6 +476,23 @@ describe('lambda', () => {
476
476
} ) ;
477
477
} ) ;
478
478
479
+ it ( 'kills lambda after configured timeout if larger than max_idle' , ( done ) => {
480
+ sinon . stub ( log , 'warn' ) ;
481
+
482
+ lambda = Lambda . create ( {
483
+ max_idle : 25 ,
484
+ env : {
485
+ AWS_PROFILE : 'local'
486
+ }
487
+ } ) ;
488
+
489
+ lambda . invoke ( 'timeout-file' , { } , ( err ) => {
490
+ assert . json ( err , { code : 'E_TIMEOUT' } ) ;
491
+ assert . calledOnce ( log . warn ) ;
492
+ done ( ) ;
493
+ } ) ;
494
+ } ) ;
495
+
479
496
it ( 'does not fail to talk to lambda after two where killed' , ( done ) => {
480
497
sinon . stub ( log , 'warn' ) ;
481
498
You can’t perform that action at this time.
0 commit comments