Handle unique session errors.
This commit is contained in:
@@ -37,6 +37,7 @@ export async function getSession(req) {
|
|||||||
let session = await getSessionByUuid(session_uuid);
|
let session = await getSessionByUuid(session_uuid);
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
|
try {
|
||||||
session = await createSession(website_id, {
|
session = await createSession(website_id, {
|
||||||
session_uuid,
|
session_uuid,
|
||||||
hostname,
|
hostname,
|
||||||
@@ -47,6 +48,11 @@ export async function getSession(req) {
|
|||||||
country,
|
country,
|
||||||
device,
|
device,
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (!e.message.includes('Unique constraint')) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { session_id } = session;
|
const { session_id } = session;
|
||||||
|
|||||||
Reference in New Issue
Block a user