File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export const formatWorkflowError = (error: unknown): FailureFunctionPayload => {
67
67
? {
68
68
error : error . name ,
69
69
message : error . message ,
70
+ stack : error . stack ,
70
71
}
71
72
: {
72
73
error : "Error" ,
Original file line number Diff line number Diff line change @@ -322,6 +322,7 @@ describe("serve", () => {
322
322
expect ( result ) . toEqual ( {
323
323
error : "Error" ,
324
324
message : "some-error" ,
325
+ stack : expect . any ( String ) ,
325
326
} ) ;
326
327
called = true ;
327
328
} ,
@@ -903,6 +904,7 @@ describe("serve", () => {
903
904
expect ( body ) . toEqual ( {
904
905
error : "WorkflowNonRetryableError" ,
905
906
message : "This is a non-retryable error" ,
907
+ stack : expect . any ( String ) ,
906
908
} ) ;
907
909
} ,
908
910
responseFields : { body : undefined , status : 489 } ,
@@ -1227,6 +1229,7 @@ describe("serve", () => {
1227
1229
expect ( content ) . toEqual ( {
1228
1230
error : "WorkflowError" ,
1229
1231
message : `Workflow URL should start with 'http://' or 'https://'. Recevied is '${ url } '` ,
1232
+ stack : expect . any ( String ) ,
1230
1233
} ) ;
1231
1234
1232
1235
expect ( logSpy ) . toBeCalledWith ( "WARN" , "ENDPOINT_START" , {
Original file line number Diff line number Diff line change @@ -230,6 +230,7 @@ export type WorkflowServeOptions<
230
230
failStatus : number ;
231
231
failResponse : string ;
232
232
failHeaders : Record < string , string [ ] > ;
233
+ failStack : string ;
233
234
} ) => Promise < void | string > | void | string ;
234
235
/**
235
236
* Base Url of the workflow endpoint
@@ -360,6 +361,10 @@ export type FailureFunctionPayload = {
360
361
* error message
361
362
*/
362
363
message : string ;
364
+ /**
365
+ * error stack trace if available
366
+ */
367
+ stack ?: string ;
363
368
} ;
364
369
365
370
/**
Original file line number Diff line number Diff line change @@ -343,11 +343,15 @@ export const handleFailure = async <TInitialPayload>(
343
343
344
344
const decodedBody = body ? decodeBase64 ( body ) : "{}" ;
345
345
let errorMessage : string = "" ;
346
+ let failStack : string = "" ;
346
347
try {
347
348
const errorPayload = JSON . parse ( decodedBody ) as FailureFunctionPayload ;
348
349
if ( errorPayload . message ) {
349
350
errorMessage = errorPayload . message ;
350
351
}
352
+ if ( errorPayload . stack ) {
353
+ failStack = errorPayload . stack ;
354
+ }
351
355
} catch {
352
356
// skip
353
357
}
@@ -398,6 +402,7 @@ export const handleFailure = async <TInitialPayload>(
398
402
failStatus : status ,
399
403
failResponse : errorMessage ,
400
404
failHeaders : header ,
405
+ failStack,
401
406
} ) ;
402
407
return ok ( { result : "is-failure-callback" , response : failureResponse } ) ;
403
408
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments