* DEBUG ONLY: Trigger an artificial stream error for testing * This method allows integration tests to simulate stream errors without * mocking the AI SDK or network layer. It triggers the same error handling * path as genuine stream errors by aborting the stream and manually triggering
(workspaceId: string, errorMessage: string)
| 4135 | * causes the for-await loop to break cleanly). |
| 4136 | */ |
| 4137 | async debugTriggerStreamError(workspaceId: string, errorMessage: string): Promise<boolean> { |
| 4138 | const typedWorkspaceId = workspaceId as WorkspaceId; |
| 4139 | const streamInfo = this.workspaceStreams.get(typedWorkspaceId); |
| 4140 | |
| 4141 | // Only trigger error if stream is actively running |
| 4142 | if ( |
| 4143 | !streamInfo || |
| 4144 | (streamInfo.state !== StreamState.STARTING && streamInfo.state !== StreamState.STREAMING) |
| 4145 | ) { |
| 4146 | return false; |
| 4147 | } |
| 4148 | |
| 4149 | // Abort the stream first (causes for-await loop to break cleanly) |
| 4150 | streamInfo.abortController.abort(new Error(errorMessage)); |
| 4151 | |
| 4152 | // Mark as error state (same as catch block does) |
| 4153 | streamInfo.state = StreamState.ERROR; |
| 4154 | |
| 4155 | // Update streamInfo metadata with error (so subsequent flushes preserve it) |
| 4156 | streamInfo.initialMetadata = { |
| 4157 | ...streamInfo.initialMetadata, |
| 4158 | error: errorMessage, |
| 4159 | errorType: "network", |
| 4160 | }; |
| 4161 | |
| 4162 | // Write error state to partial.json (same as real error handling) |
| 4163 | await this.persistStreamError(typedWorkspaceId, streamInfo, { |
| 4164 | messageId: streamInfo.messageId, |
| 4165 | error: errorMessage, |
| 4166 | errorType: "network", |
| 4167 | }); |
| 4168 | |
| 4169 | // Wait for the stream processing to complete (cleanup) |
| 4170 | await streamInfo.processingPromise; |
| 4171 | |
| 4172 | return true; |
| 4173 | } |
| 4174 | } |
nothing calls this directly
no test coverage detected