()
| 176 | } |
| 177 | |
| 178 | #writeAllChunks(): Promise<void> { |
| 179 | // This code is extremely precise. |
| 180 | // You **must not** add an await here!! That will cause memory to balloon as the queue grows. |
| 181 | // It's okay to add an `await` to the caller of this method (e.g. #drainAllChunks) because that won't cause Buffer[] to be kept alive in memory. |
| 182 | return this.#fileHandle!.appendFile( |
| 183 | // This variable needs to get GC'd ASAP. |
| 184 | this.#queueToBuffers(), |
| 185 | ) |
| 186 | } |
| 187 | |
| 188 | /** Keep this in a separate method so that GC doesn't keep it alive for any longer than it should. */ |
| 189 | #queueToBuffers(): Buffer { |
no test coverage detected