diff --git a/src-electron/rest/user-data.js b/src-electron/rest/user-data.js index dbc72eea2d..ca91759806 100644 --- a/src-electron/rest/user-data.js +++ b/src-electron/rest/user-data.js @@ -330,20 +330,24 @@ function httpPostEventUpdate(db) { function httpGetInitialState(db) { return async (request, response) => { let sessionId = request.zapSessionId - let state = {} + let state = { endpointTypes: [], endpoints: [], sessionKeyValues: [] } - let session = await querySession.getSessionFromSessionId(db, sessionId) - asyncValidation.initAsyncValidation(db, session) - - let results = await Promise.all([ - queryEndpointType.selectAllEndpointTypes(db, sessionId), - queryEndpoint.selectAllEndpoints(db, sessionId), - querySession.getAllSessionKeyValues(db, sessionId), - ]) - - state.endpointTypes = results[0] - state.endpoints = results[1] - state.sessionKeyValues = results[2] + try { + let session = await querySession.getSessionFromSessionId(db, sessionId) + await asyncValidation.initAsyncValidation(db, session) + + let results = await Promise.all([ + queryEndpointType.selectAllEndpointTypes(db, sessionId), + queryEndpoint.selectAllEndpoints(db, sessionId), + querySession.getAllSessionKeyValues(db, sessionId), + ]) + + state.endpointTypes = results[0] + state.endpoints = results[1] + state.sessionKeyValues = results[2] + } catch (error) { + console.error(error) + } response.status(StatusCodes.OK).json(state) }