@@ -331,6 +331,14 @@ const prettyInternalErrors: Partial<
331331 href : links . docs . machines . home ,
332332 } ,
333333 } ,
334+ TASK_PROCESS_SIGTERM : {
335+ message :
336+ "Your task exited after receiving SIGTERM but we don't know why. If this keeps happening, please get in touch so we can investigate." ,
337+ link : {
338+ name : "Contact us" ,
339+ href : links . site . contact ,
340+ } ,
341+ } ,
334342} ;
335343
336344type EnhanceError < T extends TaskRunError | ExceptionEventProperties > = T & {
@@ -342,6 +350,14 @@ export function taskRunErrorEnhancer(error: TaskRunError): EnhanceError<TaskRunE
342350 case "BUILT_IN_ERROR" : {
343351 if ( error . name === "UnexpectedExitError" ) {
344352 if ( error . message . startsWith ( "Unexpected exit with code -1" ) ) {
353+ if ( error . message . includes ( "SIGTERM" ) ) {
354+ return {
355+ type : "INTERNAL_ERROR" ,
356+ code : TaskRunErrorCodes . TASK_PROCESS_SIGTERM ,
357+ ...prettyInternalErrors . TASK_PROCESS_SIGTERM ,
358+ } ;
359+ }
360+
345361 return {
346362 type : "INTERNAL_ERROR" ,
347363 code : TaskRunErrorCodes . TASK_PROCESS_MAYBE_OOM_KILLED ,
@@ -359,6 +375,14 @@ export function taskRunErrorEnhancer(error: TaskRunError): EnhanceError<TaskRunE
359375 }
360376 case "INTERNAL_ERROR" : {
361377 if ( error . code === TaskRunErrorCodes . TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE ) {
378+ if ( error . message ?. includes ( "SIGTERM" ) ) {
379+ return {
380+ type : "INTERNAL_ERROR" ,
381+ code : TaskRunErrorCodes . TASK_PROCESS_SIGTERM ,
382+ ...prettyInternalErrors . TASK_PROCESS_SIGTERM ,
383+ } ;
384+ }
385+
362386 return {
363387 type : "INTERNAL_ERROR" ,
364388 code : TaskRunErrorCodes . TASK_PROCESS_MAYBE_OOM_KILLED ,
@@ -396,7 +420,8 @@ export function exceptionEventEnhancer(
396420 break ;
397421 }
398422 case TaskRunErrorCodes . TASK_PROCESS_MAYBE_OOM_KILLED :
399- case TaskRunErrorCodes . TASK_PROCESS_OOM_KILLED : {
423+ case TaskRunErrorCodes . TASK_PROCESS_OOM_KILLED :
424+ case TaskRunErrorCodes . TASK_PROCESS_SIGTERM : {
400425 return {
401426 ...exception ,
402427 ...prettyInternalErrors [ exception . type ] ,
@@ -411,32 +436,45 @@ export function internalErrorFromUnexpectedExit(
411436 error : UnexpectedExitError ,
412437 dockerMode = true
413438) : TaskRunInternalError {
439+ const internalError = {
440+ type : "INTERNAL_ERROR" ,
441+ code : TaskRunErrorCodes . TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE ,
442+ message : `Process exited with code ${ error . code } after signal ${ error . signal } .` ,
443+ stackTrace : error . stderr ,
444+ } satisfies TaskRunInternalError ;
445+
414446 if ( error . code === 137 ) {
415447 if ( dockerMode ) {
416448 return {
417- type : "INTERNAL_ERROR" ,
449+ ... internalError ,
418450 code : TaskRunErrorCodes . TASK_PROCESS_OOM_KILLED ,
419451 } ;
420452 } else {
421453 // Note: containerState reason and message could be checked to clarify the error, maybe the task monitor should be allowed to override these
422454 return {
423- type : "INTERNAL_ERROR" ,
455+ ... internalError ,
424456 code : TaskRunErrorCodes . TASK_PROCESS_MAYBE_OOM_KILLED ,
425457 } ;
426458 }
427459 }
428460
429461 if ( error . stderr ?. includes ( "OOMErrorHandler" ) ) {
430462 return {
431- type : "INTERNAL_ERROR" ,
463+ ... internalError ,
432464 code : TaskRunErrorCodes . TASK_PROCESS_OOM_KILLED ,
433465 } ;
434466 }
435467
468+ if ( error . signal === "SIGTERM" ) {
469+ return {
470+ ...internalError ,
471+ code : TaskRunErrorCodes . TASK_PROCESS_SIGTERM ,
472+ } ;
473+ }
474+
436475 return {
437- type : "INTERNAL_ERROR" ,
476+ ... internalError ,
438477 code : TaskRunErrorCodes . TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE ,
439- message : `Process exited with code ${ error . code } after signal ${ error . signal } .` ,
440478 } ;
441479}
442480
0 commit comments