Improve performance of uploading file to block blob: use fs.stat() instead of fs.statSync() #5056
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
enhancement
good first issue
This issue tracks work that may be a good starting point for a first-time contributor
Storage
Storage Service (Queues, Blobs, Files)
@azure/storage-blob
10.4.1
macOs
v12.5.0
Chrome 76 on macOS (Mojave)
3.2.2
Describe the bug
File Name: highlevel.node.ts
** Function :** uploadFileToBlockBlob : 39
Before uploading the file, you are using 'fs.statSync' in order to get the size of the file, probably to use it has Content-Length.
The use of a synchronous function is severe, certainly with the use of Promises.
Once you adopt Promises pattern for writing asynchronous code but still using dependency with synchronous functions, you can cause the main thread to be block. (for example using Promises.all).
To Reproduce
Steps to reproduce the behavior:
1.
Expected behavior
Use 'fs.stat' instead of 'fs.statSync' and use await within the function.
When you await a promise, the function is paused in a non-blocking way until the promise settles.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: