Skip to content

Commit

Permalink
fix(chromecast): Speed up shutdown (#78)
Browse files Browse the repository at this point in the history
After we launch the requested receiver app, we should shut down the connection explicitly.  Otherwise, the socket has to time out before the calling application in nodejs can terminate.  This is because nodejs keeps the main thread running so long as anything async could occur, including events on handles and sockets.
  • Loading branch information
joeyparrish authored Sep 15, 2023
1 parent 801522e commit 89f4146
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backends/chromecast/cast-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ function cast(flags, log, mode, url) {
// The request was fulfilled.
log.info('Cast successful.');
clearTimeout(connectionTimer);
client.close();
resolve();
} else if (request.type == 'STOP' && homeLaunched) {
// The home screen is showing.
log.info('Return to home screen successful.');
clearTimeout(connectionTimer);
client.close();
resolve();
} else if (data.type == 'LAUNCH_ERROR') {
const message = 'Failed to launch receiver! Reason: ' + data.reason;
Expand Down

0 comments on commit 89f4146

Please sign in to comment.