Skip to content

fix: don't fire OnCardRemoved on fatal communication errors#39

Merged
wizzomafizzo merged 1 commit intomainfrom
fix/no-card-removed-on-fatal-error
Jan 17, 2026
Merged

fix: don't fire OnCardRemoved on fatal communication errors#39
wizzomafizzo merged 1 commit intomainfrom
fix/no-card-removed-on-fatal-error

Conversation

@wizzomafizzo
Copy link
Member

Summary

  • When the PN532 device is unplugged or experiences a fatal communication error, the library was incorrectly firing OnCardRemoved before OnDeviceDisconnected
  • This gave callers false information - the card wasn't removed, the reader disconnected
  • Now handlePollingError() checks for fatal errors first and returns early, skipping handleCardRemoval()

Test plan

  • Added TestSession_FatalErrorDoesNotTriggerCardRemoved test
  • make check passes (lint + tests + deadlock detection)

When the PN532 device is unplugged or experiences a fatal error,
the library was incorrectly firing OnCardRemoved before
OnDeviceDisconnected. This gives callers false information - the
card wasn't removed, the reader disconnected.

Now handlePollingError() checks for fatal errors first and returns
early after calling OnDeviceDisconnected, skipping handleCardRemoval().
@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@wizzomafizzo wizzomafizzo merged commit 6734fa6 into main Jan 17, 2026
13 checks passed
@wizzomafizzo wizzomafizzo deleted the fix/no-card-removed-on-fatal-error branch January 17, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant