Skip to content

Commit 0b81208

Browse files
committed
Prefer microtask to timeout in write queue
This seems to make little difference but it's more correct as we want to write as fast as possible to minimize input latency
1 parent c6e4788 commit 0b81208

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/common/input/WriteBuffer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class WriteBuffer {
105105
// schedule chunk processing for next event loop run
106106
if (!this._writeBuffer.length) {
107107
this._bufferOffset = 0;
108-
setTimeout(() => this._innerWrite());
108+
queueMicrotask(() => this._innerWrite());
109109
}
110110

111111
this._pendingData += data.length;
@@ -217,7 +217,7 @@ export class WriteBuffer {
217217
this._callbacks = this._callbacks.slice(this._bufferOffset);
218218
this._bufferOffset = 0;
219219
}
220-
setTimeout(() => this._innerWrite());
220+
queueMicrotask(() => this._innerWrite());
221221
} else {
222222
this._writeBuffer.length = 0;
223223
this._callbacks.length = 0;

0 commit comments

Comments
 (0)