diff --git a/packages/api/src/elastic/pages.ts b/packages/api/src/elastic/pages.ts index fc4671be2..6b9c679d8 100644 --- a/packages/api/src/elastic/pages.ts +++ b/packages/api/src/elastic/pages.ts @@ -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 => { 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({ diff --git a/packages/api/src/server.ts b/packages/api/src/server.ts index f1193f830..886173432 100755 --- a/packages/api/src/server.ts +++ b/packages/api/src/server.ts @@ -210,8 +210,6 @@ const main = async (): Promise => { 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 => { 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 diff --git a/packages/thumbnail-handler/src/index.ts b/packages/thumbnail-handler/src/index.ts index 7fa2472fa..301103d15 100644 --- a/packages/thumbnail-handler/src/index.ts +++ b/packages/thumbnail-handler/src/index.ts @@ -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...')