pinojs / sonic-boom

Extremely fast utf8 only stream implementation
MIT License
261 stars 41 forks source link

Sync option ignored, when minLength exists #175

Closed darky closed 1 year ago

darky commented 1 year ago
new SonicBoom({ minLength: 4096, sync: true })

☝️ will use async logging, because minLength exists But it's implicit confusing behaviour Expecting sync logging, sync option should have much more priority here

mcollina commented 1 year ago

It does not work the way you think it is. The sync refers to how the data is written out to the final destination - sync: true will block the event loop. minLength controls the minimum size of data that is written every time.

Setting sync: true with minLength: 4096 will look like asynchronous as most time the log is written in the future, but in reality it's written when the threshold is crossed.