From fc46aaaa44422668c19c548d1a1e7ff0add4880f Mon Sep 17 00:00:00 2001 From: dblock Date: Sun, 5 Feb 2017 09:19:46 -0500 Subject: [PATCH] Fix #157: SessionEndedRequest hangs without a defined sessionEndedFunc. --- CHANGELOG.md | 1 + index.js | 2 ++ test/test_alexa_app_session_ended_request.js | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55ff938..6e0108a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * [#119](https://github.com/alexa-js/alexa-app/pull/119): Moved to the [alexa-js organization](https://github.com/alexa-js) - [@dblock](https://github.com/dblock). * [#118](https://github.com/matt-kruse/alexa-app/pull/118), [#117](https://github.com/matt-kruse/alexa-app/issues/117): Prevent updating session attributes directly - [@ajcrites](https://github.com/ajcrites). * [#133](https://github.com/matt-kruse/alexa-app/pull/133), [#71](https://github.com/matt-kruse/alexa-app/issues/71): Support asynchronous patterns in request handlers - [@ajcrites](https://github.com/ajcrites). +* [#159](https://github.com/alexa-js/alexa-app/pull/159), [#157](https://github.com/alexa-js/alexa-app/issues/157): Fixed `SessionEndedRequest` hangs without a defined `sessionEndedFunc` - [@dblock](https://github.com/dblock). * Your contribution here. ### 2.4.0 (January 5, 2017) diff --git a/index.js b/index.js index b7874b0..0f7b783 100644 --- a/index.js +++ b/index.js @@ -451,6 +451,8 @@ alexa.app = function(name) { } else if (false !== sessionEndedResult) { callbackHandler(); } + } else { + response.send(); } } else if (request.isAudioPlayer()) { var event = requestType.slice(12); diff --git a/test/test_alexa_app_session_ended_request.js b/test/test_alexa_app_session_ended_request.js index fdf9fba..4d7f84d 100644 --- a/test/test_alexa_app_session_ended_request.js +++ b/test/test_alexa_app_session_ended_request.js @@ -37,6 +37,19 @@ describe("Alexa", function() { version: "1.0" }); }); + + it("returns a response without a defined sessionEnded function", function() { + var subject = testApp.request(mockRequest); + + return expect(subject).to.eventually.become({ + response: { + directives: [], + shouldEndSession: true + }, + sessionAttributes: {}, + version: "1.0" + }); + }); }); }); });