Repository navigation
Conversation
Nerivec
force-pushed
the
serialport-napi-rs
branch
from
November 13, 2026 21:16
708c3c3 to
1886d03
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This will stay a draft until (at least) Node 22 EOL (Spring 2027), which will EOL 32-bit platforms, and allow us to move to this without too much trouble.
Important
This is experimental. We need a good amount of time for tests, and improvements. Feedback wanted!
We'll provide easier ways to test this once the basics are ironed out (currently requires building and overriding zigbee-herdsman locally).
Uses Rust-based
NAPI-RSwithtokio-serialinstead of the oldbindings-cppfrom@serialport/stream.The async binding API (though not yet finalized) is purposely kept very simple, as much as possible is delegated to tokio-serial, serialport & NAPI-RS, making it a "thin passthrough".
The current behavior is kept simple for several reasons, but mainly because this particular use is largely untested.
The simplistic initial approach will allow us to "strengthen" various aspects from actual observations rather than guesses; avoiding a crowded codebase for no good reason.
The TODO list at the bottom should cover these aspects in more details.
Worth noting that, as opposed to the previous package which published all binaries in one package, per NAPI-RS guidelines, this uses platform-specific optional dependencies; each installation, based on its platform, only gets the binary it needs.
Also worth noting that it is possible to override the binding's path with env
NAPI_RS_NATIVE_LIBRARY_PATH, which skips the default logic ("detect platform then find binding in selected dependency").Any review from Rust enthusiasts welcomed! https://github.com/Koenkk/serialport-napi-rs/blob/main/src/lib.rs
The current codebase is no more than a basic tokio loop (stream + command channel) with a basic napi-rs integration (a "make it work" sample). No doubt there is a lot of room for improvements, however, as mentioned above, we're looking for "real" improvements, rather than complicating the codebase for the sake of it; goal is to keep this a "thin passthrough", delegate to libraries.
Current tests (baremetal Debian 13 x64) show a rather drastic increase in performance:
hardware: TI CC2674P10 with CP210x, baudrate: 115200, flow: none
500+ samples (a whole-network startup+shutdown with TI stack)
hardware: Silabs MG24 with CP210x, baudrate: 460800, flow: none
50+ samples (a whole-network startup+shutdown with Silabs stack)
Note: These numbers remain tiny in the "grand scheme" of things. However this should drastically reduce the various timeout issues observed in lower layers in "less reliable" setups.
TODO:
CC: @andrei-lazarov @chris-1243 @thk-socal @manup @kirovilya @Gnarfoz
Please respect the AI policy for any report/post.