diff --git a/lib/protocol/protocol.js b/lib/protocol/protocol.js index 6e4c6fca9..fd457dc4b 100644 --- a/lib/protocol/protocol.js +++ b/lib/protocol/protocol.js @@ -236,13 +236,10 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) { let newSessionId; let currentProtocol = extractProtocol(driver, req.params.sessionId); - let terminateSocket = false; - try { // if this is a session command but we don't have a session, // error out early (especially before proxying) if (isSessCmd && !driver.sessionExists(req.params.sessionId)) { - terminateSocket = true; throw new errors.NoSuchDriverError(); } @@ -334,7 +331,6 @@ function buildHandler (app, method, path, spec, driver, isSessCmd) { // delete should not return anything even if successful if (spec.command === DELETE_SESSION_COMMAND) { - terminateSocket = true; SESSIONS_CACHE.getLogger(req.params.sessionId, currentProtocol) .debug(`Received response: ${_.truncate(JSON.stringify(driverRes), {length: MAX_LOG_BODY_LENGTH})}`); SESSIONS_CACHE.getLogger(req.params.sessionId, currentProtocol).debug('But deleting session, so not returning'); @@ -398,12 +394,6 @@ 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 @@ -427,12 +417,6 @@ 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) => {