File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,8 @@ function forkLambda(
231231 invoke ( event , context , callback ) {
232232 if ( idle_timer ) {
233233 clearTimeout ( idle_timer ) ;
234+ idle_timer = null ;
234235 }
235- idle_timer = setTimeout ( kill , max_idle ) ;
236236 const i = ++ id ;
237237 const ms_timeout = timeout * 1000 ;
238238 if ( ! inspect_lambda ) {
@@ -247,6 +247,8 @@ function forkLambda(
247247 clearTimeout ( timeout_timer ) ;
248248 if ( graceful_shutdown ) {
249249 kill ( ) ;
250+ } else if ( ! err ) {
251+ idle_timer = setTimeout ( kill , max_idle ) ;
250252 }
251253 callback ( err , value ) ;
252254 } ;
Original file line number Diff line number Diff line change @@ -476,6 +476,23 @@ describe('lambda', () => {
476476 } ) ;
477477 } ) ;
478478
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+
479496 it ( 'does not fail to talk to lambda after two where killed' , ( done ) => {
480497 sinon . stub ( log , 'warn' ) ;
481498
You can’t perform that action at this time.
0 commit comments