* Bounds the finalOutput field. Trace spans are never included; the payload * travels through the job queue, so large outputs are serialized and * truncated instead of being passed through whole.
(finalOutput: unknown)
| 18 | * truncated instead of being passed through whole. |
| 19 | */ |
| 20 | function boundFinalOutput(finalOutput: unknown): unknown { |
| 21 | if (finalOutput === undefined || finalOutput === null) return null |
| 22 | |
| 23 | try { |
| 24 | const serialized = JSON.stringify(finalOutput) |
| 25 | if (serialized === undefined) return null |
| 26 | if (serialized.length <= SIM_FINAL_OUTPUT_MAX_BYTES) return finalOutput |
| 27 | const suffix = '... [truncated]' |
| 28 | return truncate(serialized, SIM_FINAL_OUTPUT_MAX_BYTES - suffix.length, suffix) |
| 29 | } catch { |
| 30 | return null |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | function basePayload(params: { |
| 35 | event: SimEventType |
no test coverage detected