-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to shut down an application cleanly? #70
Comments
@martinpaljak thanks for the detailed report. WRT
You're right. This could be done with only one |
I tried to read and fix some, but got lost in the code and how threads are handled with libuv (?) and ... I might come back to this at some later time or with #71 , right now process.exit() is OK for me. |
@martinpaljak This can easily be avoided if you simply set an error listener on the main pcsc object. I ran into the same problem (SCardCancel error notification on pcsc.close(), which is indeed unexpected), and I noticed that this output is done from the node EventEmitter code, which treats "error" events as a special case and prints the message when there is no listener. So, as an easy fix, just set an empty listener:
Or, if you want to handle the errors from the listener but only ignore the SCardCancel case, set a flag before doing pcsc.close() and, in your listener, ignore any error that may arise after set flag is set. |
I am a bit confused about cleanly closing the runtime after I am done with the reader I am interested in.
There is
reader.disconnect()
which is a wrapper aroundSCardDisconnect()
, thus I obviously call it.Then there is
reader.close()
which is intended to callSCardCancel()
(for this specific reader?). I call it and get no errors.Then there is
pcsc.close()
which is intended to also callSCardCancel()
(for PnP reader tracking?). I call it and get an error event on pcsc:SCardGetStatusChange error: Command cancelled.(0x80100002)
. And the node process does not exit after this call. AFAIUSCardGetStatusChange
should never emit an error if it is cancelled (I suspect this is a bug)Two questions:
process.exit()
?SCardGetStatusChange
should be sufficient, also for getting events for the pnp pseudo-reader as well as any connected readers, to be able to emit reade events (thus apcsc.close()
should be sufficient, and should result in normal exit of nodejs runtime?)The text was updated successfully, but these errors were encountered: