* Wait for messages and return all messages with the same mode as a single string * Returns { message: string, mode: T } or null if aborted/closed
(abortSignal?: AbortSignal)
| 315 | * Returns { message: string, mode: T } or null if aborted/closed |
| 316 | */ |
| 317 | async waitForMessagesAndGetAsString(abortSignal?: AbortSignal): Promise<{ message: string, mode: T, isolate: boolean, hash: string } | null> { |
| 318 | // If we have messages, return them immediately |
| 319 | if (this.queue.length > 0) { |
| 320 | return this.collectBatch(); |
| 321 | } |
| 322 | |
| 323 | // If closed or already aborted, return null |
| 324 | if (this.closed || abortSignal?.aborted) { |
| 325 | return null; |
| 326 | } |
| 327 | |
| 328 | // Wait for messages to arrive |
| 329 | const hasMessages = await this.waitForMessages(abortSignal); |
| 330 | |
| 331 | if (!hasMessages) { |
| 332 | return null; |
| 333 | } |
| 334 | |
| 335 | return this.collectBatch(); |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * Collect a batch of messages with the same mode, respecting isolation requirements |
no test coverage detected