Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle exception for httpGetInitialState() gracefully. #900

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src-electron/rest/user-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down