Add Cors headers to lamda timeout so they can be detected on the FE
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
stlToGeometry,
|
||||
createHealthyResponse,
|
||||
createUnhealthyResponse,
|
||||
timeoutErrorMessage,
|
||||
} from './common'
|
||||
|
||||
export const render = async ({ code }) => {
|
||||
@@ -29,6 +30,9 @@ export const render = async ({ code }) => {
|
||||
},
|
||||
}
|
||||
}
|
||||
if (response.status === 502) {
|
||||
return createUnhealthyResponse(new Date(), timeoutErrorMessage)
|
||||
}
|
||||
const data = await response.json()
|
||||
const geometry = await stlToGeometry(data.url)
|
||||
return createHealthyResponse({
|
||||
|
||||
@@ -38,3 +38,5 @@ export function createUnhealthyResponse(date, message = 'network issue') {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const timeoutErrorMessage = `timeout: We're currently limited a 30s execution time. You can try again, sometimes it works the second time`
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
stlToGeometry,
|
||||
createHealthyResponse,
|
||||
createUnhealthyResponse,
|
||||
timeoutErrorMessage,
|
||||
} from './common'
|
||||
|
||||
export const render = async ({ code, settings }) => {
|
||||
@@ -49,6 +50,9 @@ export const render = async ({ code, settings }) => {
|
||||
const cleanedErrorMessage = cleanError(error)
|
||||
return createUnhealthyResponse(new Date(), cleanedErrorMessage)
|
||||
}
|
||||
if (response.status === 502) {
|
||||
return createUnhealthyResponse(new Date(), timeoutErrorMessage)
|
||||
}
|
||||
const data = await response.json()
|
||||
const type = data.type !== 'stl' ? 'png' : 'geometry'
|
||||
const newData = data.type !== 'stl' ? data.url : stlToGeometry(data.url)
|
||||
@@ -81,6 +85,9 @@ export const stl = async ({ code, settings }) => {
|
||||
const cleanedErrorMessage = cleanError(error)
|
||||
return createUnhealthyResponse(new Date(), cleanedErrorMessage)
|
||||
}
|
||||
if (response.status === 502) {
|
||||
return createUnhealthyResponse(new Date(), timeoutErrorMessage)
|
||||
}
|
||||
const data = await response.json()
|
||||
const geometry = await stlToGeometry(data.url)
|
||||
return createHealthyResponse({
|
||||
|
||||
Reference in New Issue
Block a user