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,