Skip to content
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

Unhandled exception in unsubscribe from closeDueToPing #198

Open
MattiasCL opened this issue Feb 15, 2021 · 0 comments
Open

Unhandled exception in unsubscribe from closeDueToPing #198

MattiasCL opened this issue Feb 15, 2021 · 0 comments

Comments

@MattiasCL
Copy link

Had a process crash following a disconnect from the NATS server with this stack trace:

NATS.Client.NATSConnectionClosedException: Connection is closed.
   at NATS.Client.Subscription.unsubscribe(Boolean throwEx)
   at NATS.Client.AsyncSubscription.Unsubscribe()
   at STAN.Client.Connection.cleanupOnClose(Exception ex)
   at STAN.Client.Connection.closeDueToPing(Exception ex)
   at STAN.Client.Connection.pingServer(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()

Had a brief look in the source code: cleanupOnClose only unsubscribes the ackSubscription and pingSubscription if the NATS connection isn't already closed, and unsubscribe throws if called on a closed subscription. The connection's internal mutex isn't held in between those checks, so my guess is that there's a chance for a data race with the connection closing between cleanupOnClose and unsubscribe.

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

No branches or pull requests

1 participant