r/javascript
•
u/dragon-95
•
25d ago
•
1
1
1
serialport-rs for Node.js: Rust-backed serial ports for Node.js with parallel I/O and SerialPort-compatible APIs
https://github.com/DragonWork/node-serialport-rsI recently ran into an issue with @serialport/bindings-cpp on Node.js 26.4, where serial reads could stall until unrelated JavaScript activity occurred.
While investigating the issue and contributing fixes upstream, I started experimenting with an alternative implementation using Rust and N-API, because upstream seems to be unmaintained for more than a year now.
The result is serialport-rs for Node.js, which uses the existing Rust serialport crate underneath and aims to preserve the familiar Node.js SerialPort API.
The implementation uses dedicated native I/O workers rather than relying on JavaScript-side polling. Initial benchmarks have also shown some promising latency improvements.
It’s available on npm if anyone is interested in trying it:
https://www.npmjs.com/package/serialport-rs
1
u/ortegaj50 6d ago
Dedicated I/O workers should help avoid JS-side polling. How do they preserve read ordering and close/error behavior?
2
u/Unable-Ad-9092 1d ago •
Thanks! Amazing library! Works fine even with termios2 / 3.25 MBps.