* Persist error state and emit error events for failed streams.
(
workspaceId: WorkspaceId,
streamInfo: WorkspaceStreamInfo,
error: unknown
)
| 3062 | * Persist error state and emit error events for failed streams. |
| 3063 | */ |
| 3064 | private async handleStreamFailure( |
| 3065 | workspaceId: WorkspaceId, |
| 3066 | streamInfo: WorkspaceStreamInfo, |
| 3067 | error: unknown |
| 3068 | ): Promise<void> { |
| 3069 | streamInfo.state = StreamState.ERROR; |
| 3070 | |
| 3071 | const workspaceLog = this.getWorkspaceLogger(workspaceId, streamInfo); |
| 3072 | |
| 3073 | // Log the actual error for debugging |
| 3074 | workspaceLog.error("Stream processing error:", error); |
| 3075 | |
| 3076 | // Record lost previousResponseId so future requests can filter it out |
| 3077 | this.recordLostResponseIdIfApplicable(workspaceId, error, streamInfo, workspaceLog); |
| 3078 | |
| 3079 | const errorPayload = this.buildStreamErrorPayload(streamInfo, error); |
| 3080 | await this.persistStreamError(workspaceId, streamInfo, errorPayload); |
| 3081 | } |
| 3082 | |
| 3083 | private buildStreamErrorPayload( |
| 3084 | streamInfo: WorkspaceStreamInfo, |
no test coverage detected