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
This commit is contained in:
Alexandre Bourdin 2022-03-04 16:17:16 +01:00 committed by Copybot
parent 9ba3f04491
commit b1b9b9132a
3 changed files with 6 additions and 3 deletions

View file

@ -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 // Add 64kb overhead for the JSON encoding, and double the size to allow for ranges in the json payload
app.post( app.post(
'/project/:project_id/doc/:doc_id', '/project/:project_id/doc/:doc_id',
bodyParser.json({ limit: (Settings.max_doc_length + 64 * 1024) * 2 }), bodyParser.json({ limit: Settings.maxJsonRequestSize }),
HttpController.updateDoc HttpController.updateDoc
) )
app.patch( app.patch(

View file

@ -37,6 +37,9 @@ 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:
parseInt(process.env.MAX_JSON_REQUEST_SIZE) || 6 * 1024 * 1024, // 6 MB
archiveBatchSize: parseInt(process.env.ARCHIVE_BATCH_SIZE, 10) || 50, archiveBatchSize: parseInt(process.env.ARCHIVE_BATCH_SIZE, 10) || 50,
unArchiveBatchSize: parseInt(process.env.UN_ARCHIVE_BATCH_SIZE, 10) || 50, unArchiveBatchSize: parseInt(process.env.UN_ARCHIVE_BATCH_SIZE, 10) || 50,
destroyBatchSize: parseInt(process.env.DESTROY_BATCH_SIZE, 10) || 2000, destroyBatchSize: parseInt(process.env.DESTROY_BATCH_SIZE, 10) || 2000,

View file

@ -486,9 +486,9 @@ describe('Applying updates to a doc', function () {
beforeEach(function (done) { beforeEach(function (done) {
const line = new Array(1025).join('x') // 1kb const line = new Array(1025).join('x') // 1kb
this.largeLines = Array.apply(null, Array(1024)).map(() => line) // 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 () => line
) // 4mb ) // 6mb
return DocstoreClient.updateDoc( return DocstoreClient.updateDoc(
this.project_id, this.project_id,
this.doc_id, this.doc_id,