@@ -76,6 +76,58 @@ export function isManualOutOfMemoryError(error: TaskRunError) {
7676 return false ;
7777}
7878
79+ export function isOOMRunError ( error : TaskRunError ) {
80+ if ( error . type === "INTERNAL_ERROR" ) {
81+ if (
82+ error . code === "TASK_PROCESS_OOM_KILLED" ||
83+ error . code === "TASK_PROCESS_MAYBE_OOM_KILLED"
84+ ) {
85+ return true ;
86+ }
87+
88+ // For the purposes of retrying on a larger machine, we're going to treat this is an OOM error.
89+ // This is what they look like if we're executing using k8s. They then get corrected later, but it's too late.
90+ // {"code": "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE", "type": "INTERNAL_ERROR", "message": "Process exited with code -1 after signal SIGKILL."}
91+ if (
92+ error . code === "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE" &&
93+ error . message &&
94+ error . message . includes ( "-1" )
95+ ) {
96+ if ( error . message . includes ( "SIGKILL" ) ) {
97+ return true ;
98+ }
99+
100+ if ( error . message . includes ( "SIGABRT" ) && error . stackTrace ) {
101+ const oomIndicators = [
102+ "JavaScript heap out of memory" ,
103+ "Reached heap limit" ,
104+ "FATAL ERROR: Reached heap limit Allocation failed" ,
105+ ] ;
106+
107+ if ( oomIndicators . some ( ( indicator ) => error . stackTrace ! . includes ( indicator ) ) ) {
108+ return true ;
109+ }
110+ }
111+ }
112+ }
113+
114+ if ( error . type === "BUILT_IN_ERROR" ) {
115+ // ffmpeg also does weird stuff
116+ // { "name": "Error", "type": "BUILT_IN_ERROR", "message": "ffmpeg was killed with signal SIGKILL" }
117+ if ( error . message && error . message . includes ( "ffmpeg was killed with signal SIGKILL" ) ) {
118+ return true ;
119+ }
120+ }
121+
122+ // Special `OutOfMemoryError` for doing a manual OOM kill.
123+ // Useful if a native library does an OOM but doesn't actually crash the run and you want to manually
124+ if ( isManualOutOfMemoryError ( error ) ) {
125+ return true ;
126+ }
127+
128+ return false ;
129+ }
130+
79131export class TaskPayloadParsedError extends Error {
80132 public readonly cause : unknown ;
81133
@@ -562,6 +614,8 @@ const findSignalInMessage = (message?: string, truncateLength = 100) => {
562614 return "SIGSEGV" ;
563615 } else if ( trunc . includes ( "SIGKILL" ) ) {
564616 return "SIGKILL" ;
617+ } else if ( trunc . includes ( "SIGABRT" ) ) {
618+ return "SIGABRT" ;
565619 } else {
566620 return ;
567621 }
@@ -587,6 +641,10 @@ export function taskRunErrorEnhancer(error: TaskRunError): EnhanceError<TaskRunE
587641 return {
588642 ...getPrettyTaskRunError ( "TASK_PROCESS_MAYBE_OOM_KILLED" ) ,
589643 } ;
644+ case "SIGABRT" :
645+ return {
646+ ...getPrettyTaskRunError ( "TASK_PROCESS_MAYBE_OOM_KILLED" ) ,
647+ } ;
590648 default :
591649 return {
592650 ...getPrettyTaskRunError ( "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE" ) ,
@@ -636,6 +694,10 @@ export function taskRunErrorEnhancer(error: TaskRunError): EnhanceError<TaskRunE
636694 return {
637695 ...getPrettyTaskRunError ( "TASK_PROCESS_MAYBE_OOM_KILLED" ) ,
638696 } ;
697+ case "SIGABRT" :
698+ return {
699+ ...getPrettyTaskRunError ( "TASK_PROCESS_MAYBE_OOM_KILLED" ) ,
700+ } ;
639701 default : {
640702 return {
641703 ...getPrettyTaskRunError ( "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE" ) ,
@@ -689,6 +751,11 @@ export function exceptionEventEnhancer(
689751 ...exception ,
690752 ...getPrettyExceptionEvent ( "TASK_PROCESS_MAYBE_OOM_KILLED" ) ,
691753 } ;
754+ case "SIGABRT" :
755+ return {
756+ ...exception ,
757+ ...getPrettyExceptionEvent ( "TASK_PROCESS_MAYBE_OOM_KILLED" ) ,
758+ } ;
692759 default :
693760 return exception ;
694761 }
0 commit comments