Error Flashing OS to SD Card Using Etcher-SDK

I’m currently working on a Node.js application where I need to flash an OS image to an SD card. I’m using the Etcher-SDK library, specifically the usbboot.ts example from the GitHub repository. Here’s how I’m running the code: $ node dist/app.js my-os.img.

Issue: After executing the code, I encounter the following sequence of console logs:

“Waiting for USB drive to be attached…”
“USB drive attached: /dev/sdb”
“Writing image my-os.img to USB drive /dev/sdb”
Error: “Error: EBADF: bad file descriptor, write” on /dev/sdb

Could you please provide guidance on resolving this error? and able to flash the os after running this code, Any assistance or suggestions would be greatly appreciated.