(
scheduleOnFailure = true,
terminalStatus?: TerminalExecutionStreamStatus
)
| 875 | } |
| 876 | |
| 877 | const flushPending = async ( |
| 878 | scheduleOnFailure = true, |
| 879 | terminalStatus?: TerminalExecutionStreamStatus |
| 880 | ): Promise<boolean> => { |
| 881 | while (true) { |
| 882 | if (flushPromise) { |
| 883 | const ok = await flushPromise |
| 884 | if (!ok) return false |
| 885 | continue |
| 886 | } |
| 887 | if (pending.length === 0) return true |
| 888 | |
| 889 | flushPromise = doFlush(terminalStatus) |
| 890 | let ok = false |
| 891 | try { |
| 892 | ok = await flushPromise |
| 893 | } finally { |
| 894 | flushPromise = null |
| 895 | } |
| 896 | if (!ok) { |
| 897 | if (scheduleOnFailure && pending.length > 0) scheduleFlush(getFlushDelayMs()) |
| 898 | return false |
| 899 | } |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | const writeCore = async (event: ExecutionEvent): Promise<ExecutionEventEntry> => { |
| 904 | if (nextEventId === 0 || nextEventId > maxReservedId) { |
no test coverage detected