Skip to content

v3.9.0

Choose a tag to compare

@tomkp tomkp released this 18 Nov 11:26
72d5b22

Behaviour changes

Worth knowing before upgrading. Each one fixes a bug, but apps can see the difference:

  • Service outages are reported (#156). If the PC/SC service (pcscd, or the Windows Smart Card service) stays down for more than about a second, Devices reports every reader detached, and their cards removed. When the service returns, the readers are attached again with their cards. A card held through a shorter outage is reported removed, then inserted, as a new Card, because its old handle died with the service. On Windows the service stops when the last reader is unplugged, so this is also how that unplug is reported.
  • Context.cancel() ends every waitForChange() pending on the context (#161). It also ends a wait that hasn't started yet, and it no longer throws. close() ends pending waits the same way. Each wait that hadn't returned resolves with null.

Bug Fixes

Reader and card events

  • Changes made between two waits are no longer missed (#150, #153):
    • a card swapped between waits is reported as card-removed then card-inserted (pcsc-lite);
    • a reader plugged in between waits is announced: at once on pcsc-lite 2.3.0+, otherwise within about a second;
    • a reader unplugged between waits no longer makes the monitor deaf to every reader on Linux.
  • A card inserted during a service outage is connected once the service returns (#151). Before, it failed on the dead context.
  • Recovering from an outage on Windows no longer depends on which error code WinSCard returns (#156). stop() during an outage returns at once instead of waiting up to a second.
  • Devices recovers if replacing its context after an outage fails (#160). Before, it stayed without a context, and later card insertions were silently dropped until monitoring was restarted.
  • A stopped Devices session's events no longer reach the next one (#160). After a stop()/start() in the same tick, a stale event could close the new session's context, and every card connected through it.

Worker threads

  • A worker that ends without calling stop() on a ReaderMonitor or Devices no longer crashes the process (SIGABRT on Node 24.15+ on macOS, a hang on Linux) (#152).
  • Using the addon in workers and in the main thread no longer crashes (SIGSEGV) after a worker exits (#154).
  • A worker that ends with monitor events undelivered, or with an operation in flight (waitForChange(), transmit(), connect(), ...), no longer crashes the process (SIGABRT), and no longer leaks the undelivered events (#157).
  • A worker that ends with a waitForChange() pending now finishes exiting (#158). It hung, and so did the process, since the main thread's exit waits for its workers.

waitForChange()

  • Pending waits no longer stall the rest of the process (#158). Each wait held one of Node's 4 shared threadpool threads, so four pending waits stopped all fs, dns, crypto and zlib work, and this library's transmit() and connect(). Waits queued behind them also missed cancel().
  • On Linux, a pending wait no longer locks up its Context (#161). listReaders() and close() on that context blocked the main thread until the wait ended, forever with no timeout. A second wait, or a connect(), blocked every PC/SC call in the process. Each wait now uses a PC/SC context of its own.
  • cancel() straight after waitForChange() is no longer lost (#161). Before, it lost the cancel every time on macOS, and the wait went on.

Testing

  • A TLA+ model of the reader monitor, checked in CI (#149). It found the event and teardown bugs fixed in #150 and #152. See spec/README.md.
  • Card tests run against a virtual reader and card (vsmartcard) in CI on Linux, including the integration suite, which used to skip without hardware (#155).
  • The tests run against an AddressSanitizer build of the addon in CI on Linux, Node 20, 22 and 24 (#159).
  • Checked on real hardware on macOS: card insert and remove, and plugging and unplugging the reader, with and without a card in it.

Internal

  • Development dependency updates (#141, #142, #143, #147). The only runtime dependency, node-addon-api, is unchanged.

Documentation

  • Card Spy is linked under Related Projects (#148).

Full Changelog

v3.8.0...v3.9.0