update thumbnail if failed to fetch and return url if already signed
This commit is contained in:
@ -28,6 +28,7 @@ import {
|
||||
} from './types'
|
||||
|
||||
const MAX_CONTENT_LENGTH = 10 * 1024 * 1024 // 10MB
|
||||
const CONTENT_LENGTH_ERROR = 'Your page content is too large to be saved.'
|
||||
|
||||
const appendQuery = (builder: ESBuilder, query: string): ESBuilder => {
|
||||
interface Field {
|
||||
@ -413,8 +414,7 @@ export const createPage = async (
|
||||
contentLength: page.content.length,
|
||||
})
|
||||
|
||||
page.content = 'Your page content is too large to be saved.'
|
||||
page.state = ArticleSavingRequestStatus.Failed
|
||||
page.content = CONTENT_LENGTH_ERROR
|
||||
}
|
||||
|
||||
const { body } = await client.index({
|
||||
@ -445,15 +445,13 @@ export const updatePage = async (
|
||||
ctx: PageContext
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
// max 10MB
|
||||
if (page.content && page.content.length > MAX_CONTENT_LENGTH) {
|
||||
logger.info('page content is too large', {
|
||||
pageId: page.id,
|
||||
contentLength: page.content.length,
|
||||
})
|
||||
|
||||
page.content = 'Your page content is too large to be saved.'
|
||||
page.state = ArticleSavingRequestStatus.Failed
|
||||
page.content = CONTENT_LENGTH_ERROR
|
||||
}
|
||||
|
||||
await client.update({
|
||||
|
||||
@ -210,8 +210,6 @@ const main = async (): Promise<void> => {
|
||||
logger.notice(`🚀 Server ready at ${apollo.graphqlPath}`)
|
||||
})
|
||||
|
||||
listener.timeout = 1000 * 60 * 10 // 10 minutes
|
||||
|
||||
// Avoid keepalive timeout-related connection drops manifesting in user-facing 502s.
|
||||
// See here: https://cloud.google.com/load-balancing/docs/https#timeouts_and_retries
|
||||
// and: https://cloud.google.com/appengine/docs/standard/nodejs/how-instances-are-managed#timeout
|
||||
@ -219,6 +217,7 @@ const main = async (): Promise<void> => {
|
||||
listener.keepAliveTimeout = 630 * 1000 // 30s more than the 10min keepalive used by appengine.
|
||||
// And a workaround for node.js bug: https://github.com/nodejs/node/issues/27363
|
||||
listener.headersTimeout = 640 * 1000 // 10s more than above
|
||||
listener.timeout = 640 * 1000 // match headersTimeout
|
||||
}
|
||||
|
||||
// only call main if the file was called from the CLI and wasn't required from another module
|
||||
|
||||
@ -346,7 +346,11 @@ export const thumbnailHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
console.log('thumbnail already set')
|
||||
// pre-cache thumbnail first if exists
|
||||
const imageProxyUrl = createImageProxyUrl(page.image, 320, 320)
|
||||
await fetchImage(imageProxyUrl)
|
||||
const image = await fetchImage(imageProxyUrl)
|
||||
if (!image) {
|
||||
console.log('thumbnail image not found')
|
||||
page.image = undefined
|
||||
}
|
||||
}
|
||||
|
||||
console.log('pre-caching all images...')
|
||||
|
||||
Reference in New Issue
Block a user