(content: string)
| 108 | } |
| 109 | |
| 110 | append(content: string): void { |
| 111 | if (this.#capped) { |
| 112 | return |
| 113 | } |
| 114 | // content.length (UTF-16 code units) undercounts UTF-8 bytes by at most ~3×. |
| 115 | // Acceptable for a coarse disk-fill guard — avoids re-scanning every chunk. |
| 116 | this.#bytesWritten += content.length |
| 117 | if (this.#bytesWritten > MAX_TASK_OUTPUT_BYTES) { |
| 118 | this.#capped = true |
| 119 | this.#queue.push( |
| 120 | `\n[output truncated: exceeded ${MAX_TASK_OUTPUT_BYTES_DISPLAY} disk cap]\n`, |
| 121 | ) |
| 122 | } else { |
| 123 | this.#queue.push(content) |
| 124 | } |
| 125 | if (!this.#flushPromise) { |
| 126 | this.#flushPromise = new Promise<void>(resolve => { |
| 127 | this.#flushResolve = resolve |
| 128 | }) |
| 129 | void track(this.#drain()) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | flush(): Promise<void> { |
| 134 | return this.#flushPromise ?? Promise.resolve() |
no test coverage detected