Forráskód Böngészése

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
Alexandre Bourdin 4 éve
szülő
commit
b1b9b9132a

+ 1 - 1
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(

+ 3 - 0
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,

+ 2 - 2
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,