Titanium JIRA Archive
Appcelerator Daemon (DAEMON)

[DAEMON-285] Unsubscribe in external plugin service dispatcher not called when forcefully closing connection

GitHub Issuen/a
Resolution Date2019-09-24T15:04:24.000+0000
Affected Version/sAppc Daemon 3.0.0
Fix Version/sAppc Daemon 3.1.0
ReporterJan Vennemann
AssigneeJan Vennemann


Canceling a subscription to a service dispatcher in external plugins won't properly trigger the cleanup logic since the plugin isn't notified about the end of response stream like it is happening in internal plugins. *Steps to reproduce the behavior*

Open a subscription to any internal plugin, e.g. appcd exec /appcd/status/system/memory --subscribe, and then cancel the subscription by CTRL+C

Notice that the subscription will be properly cleaned up as indicated by the following logs:

2019-09-24T10:15:47.154Z appcd:http:webserver disconnected
2019-09-24T10:15:47.155Z appcd:http:webserver closed WebSocket
2019-09-24T10:15:47.155Z appcd:service-dispatcher cleanup
2019-09-24T10:15:47.155Z appcd:service-dispatcher Stream ended, cleaning up
2019-09-24T10:15:47.155Z appcd:service-dispatcher [782e2d4a-b194-4f9a-806f-9b3cfc47b2f3] Unsubscribing: system.memory
2019-09-24T10:15:47.155Z appcd:service-dispatcher [782e2d4a-b194-4f9a-806f-9b3cfc47b2f3] No more listeners, removing descriptor: system.memory
2019-09-24T10:15:47.156Z appcd:service-dispatcher [782e2d4a-b194-4f9a-806f-9b3cfc47b2f3] Calling service's destroySubscription(): system.memory
2019-09-24T10:15:47.156Z appcd:data-service-dispatcher Removing gawk watch
2019-09-24T10:15:47.156Z appcd:core:websocket-session stream ended
2019-09-24T10:15:47.157Z appcd:core:websocket-session [0] [finish] /appcd/status/system/memory 200 2874ms

Now, do the same for an external plugin, e.g. run appcd exec /titanium/latest/sdk --subscribe and then cancel the subscription by CTRL+C

No subscription cleanup is done as you can see in the following logs

2019-09-24T10:10:04.797Z appcd:http:webserver disconnected
2019-09-24T10:10:04.797Z appcd:http:webserver closed WebSocket
2019-09-24T10:10:04.798Z appcd:core:websocket-session stream ended
2019-09-24T10:10:04.798Z appcd:core:websocket-session [0] [finish] /titanium/latest/sdk 200 7006ms
*Actual behavior* Subscriptions in external plugins are not properly cleaned up and a service dispatchers onUnsubscribe and destroySubscription are not being called. *Expected behavior* A subscriptions cleanup logic is properly being executed for external plugins.


  1. Jan Vennemann 2019-09-24

    PR: https://github.com/appcelerator/appc-daemon/pull/431

JSON Source