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