Closed connorlurring closed 2 years ago
@connorlurring Isn't writing an await
with writeAsync
and writing without an await
with write
the same?
If it is not the same, could you elaborate?
@sushantwork the write
method is poorly named, it isn't synchronous. It accepts a second argument, which is a callback. This means we end up with a race condition where in the case of small images, the write happens fast enough that there is no issue, but in the case of large images, the method does not wait for the write to complete before returning as the callback is not blocking.
Using await
and writeAsync
we can ensure that the method waits for the write to complete before continuing.
Await
writeAsync
to ensure write is complete before return.