From b1b9b9132a06131d21e15f947dc607555f7c49b0 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdin Date: Fri, 4 Mar 2022 16:17:16 +0100 Subject: [PATCH] Merge pull request #7004 from overleaf/ab-docstore-max-request-size-config Add config for body parser max request size in docstore GitOrigin-RevId: ee5cc319d44b1abdbae5b39270e56afb637bf2c7 --- services/docstore/app.js | 2 +- services/docstore/config/settings.defaults.js | 3 +++ services/docstore/test/acceptance/js/UpdatingDocsTests.js | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/services/docstore/app.js b/services/docstore/app.js index eafafeb8b5..c58dd8394d 100644 --- a/services/docstore/app.js +++ b/services/docstore/app.js @@ -56,7 +56,7 @@ app.get('/project/:project_id/doc/:doc_id/peek', HttpController.peekDoc) // Add 64kb overhead for the JSON encoding, and double the size to allow for ranges in the json payload app.post( '/project/:project_id/doc/:doc_id', - bodyParser.json({ limit: (Settings.max_doc_length + 64 * 1024) * 2 }), + bodyParser.json({ limit: Settings.maxJsonRequestSize }), HttpController.updateDoc ) app.patch( diff --git a/services/docstore/config/settings.defaults.js b/services/docstore/config/settings.defaults.js index 391739368e..2b2952076d 100644 --- a/services/docstore/config/settings.defaults.js +++ b/services/docstore/config/settings.defaults.js @@ -37,6 +37,9 @@ const Settings = { max_doc_length: parseInt(process.env.MAX_DOC_LENGTH) || 2 * 1024 * 1024, // 2mb + maxJsonRequestSize: + parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB + archiveBatchSize: parseInt(process.env.ARCHIVE_BATCH_SIZE, 10) || 50, unArchiveBatchSize: parseInt(process.env.UN_ARCHIVE_BATCH_SIZE, 10) || 50, destroyBatchSize: parseInt(process.env.DESTROY_BATCH_SIZE, 10) || 2000, diff --git a/services/docstore/test/acceptance/js/UpdatingDocsTests.js b/services/docstore/test/acceptance/js/UpdatingDocsTests.js index 91846c7a68..6ffc564a7d 100644 --- a/services/docstore/test/acceptance/js/UpdatingDocsTests.js +++ b/services/docstore/test/acceptance/js/UpdatingDocsTests.js @@ -486,9 +486,9 @@ describe('Applying updates to a doc', function () { beforeEach(function (done) { const line = new Array(1025).join('x') // 1kb this.largeLines = Array.apply(null, Array(1024)).map(() => line) // 1kb - this.originalRanges.padding = Array.apply(null, Array(4096)).map( + this.originalRanges.padding = Array.apply(null, Array(6144)).map( () => line - ) // 4mb + ) // 6mb return DocstoreClient.updateDoc( this.project_id, this.doc_id,