fix: add another condition for terminating socket
MODIFY
lib/protocol/protocol.js
lib/protocol/protocol.js
@@ -406,6 +406,12 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) {
// Use the JSONWP status code (which is usually 500)
httpStatus = jsonwpRes[0];
}
+
+ // any error while creating a session should not continue holding onto
+ // the socket
+ if (spec.command === CREATE_SESSION_COMMAND) {
+ terminateSocket = true;
+ }
}
// decode the response, which is either a string or json
@@ -428,13 +434,13 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) {
httpResBody = formatStatus(httpResBody, httpStatus, currentProtocol);
res.status(httpStatus).json(httpResBody);
+ }
// in certain situations the socket should not be kept alive
if (terminateSocket) {
SESSIONS_CACHE.getLogger(req.params.sessionId || newSessionId, currentProtocol).debug(`Destroying socket connection`);
res.socket.destroy();
}
- }
};
// add the method to the app
app[method.toLowerCase()](path, (req, res) => {

fix: add another condition for terminating socket