فهرست منبع

Merge pull request #27823 from overleaf/em-increase-max-request-size

Increase max request size in docstore and history

GitOrigin-RevId: 8ce6c023027457a65431ee5deb2f75f467914f14
Eric Mc Sween 1 سال پیش
والد
کامیت
eb2320a8af

+ 1 - 1
services/docstore/config/settings.defaults.js

@@ -41,7 +41,7 @@ const Settings = {
   max_doc_length: parseInt(process.env.MAX_DOC_LENGTH) || 2 * 1024 * 1024, // 2mb
   max_doc_length: parseInt(process.env.MAX_DOC_LENGTH) || 2 * 1024 * 1024, // 2mb
 
 
   maxJsonRequestSize:
   maxJsonRequestSize:
-    parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB
+    parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 12 * 1024 * 1024, // 6 MB
 
 
   unArchiveBatchSize: parseInt(process.env.UN_ARCHIVE_BATCH_SIZE, 10) || 50,
   unArchiveBatchSize: parseInt(process.env.UN_ARCHIVE_BATCH_SIZE, 10) || 50,
   parallelArchiveJobs: parseInt(process.env.PARALLEL_ARCHIVE_JOBS, 10) || 5,
   parallelArchiveJobs: parseInt(process.env.PARALLEL_ARCHIVE_JOBS, 10) || 5,

+ 3 - 5
services/docstore/test/acceptance/js/UpdatingDocsTests.js

@@ -521,11 +521,9 @@ describe('Applying updates to a doc', function () {
 
 
   return describe('when the json payload is too large', function () {
   return describe('when the json payload is too large', function () {
     beforeEach(function (done) {
     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(6144)).map(
-        () => line
-      ) // 6mb
+      const line = new Array(1024).join('x') // 1 KB
+      this.largeLines = new Array(8192).fill(line) // 8 MB
+      this.originalRanges.padding = new Array(6144).fill(line) // 6 MB
       return DocstoreClient.updateDoc(
       return DocstoreClient.updateDoc(
         this.project_id,
         this.project_id,
         this.doc_id,
         this.doc_id,

+ 1 - 1
services/history-v1/app.js

@@ -34,7 +34,7 @@ Metrics.leaked_sockets.monitor(logger)
 // We may have fairly large JSON bodies when receiving large Changes. Clients
 // We may have fairly large JSON bodies when receiving large Changes. Clients
 // may have to handle 413 status codes and try creating files instead of sending
 // may have to handle 413 status codes and try creating files instead of sending
 // text content in changes.
 // text content in changes.
-app.use(bodyParser.json({ limit: '6MB' }))
+app.use(bodyParser.json({ limit: '12MB' }))
 app.use(
 app.use(
   bodyParser.urlencoded({
   bodyParser.urlencoded({
     extended: false,
     extended: false,

+ 4 - 1
services/history-v1/storage/lib/persist_changes.js

@@ -119,7 +119,10 @@ async function persistChanges(projectId, allChanges, limits, clientEndVersion) {
       const change = changes[0]
       const change = changes[0]
       const changeBytes = countChangeBytes(change)
       const changeBytes = countChangeBytes(change)
 
 
-      if (totalBytes + changeBytes > limits.maxChunkChangeBytes) {
+      if (
+        chunk.getChanges().length > 0 &&
+        totalBytes + changeBytes > limits.maxChunkChangeBytes
+      ) {
         break
         break
       }
       }