From d610f404e78e48dd4dbc442f45cc2e5e21ec7759 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 27 May 2026 15:09:17 +0200 Subject: [PATCH] [history-v1] increase timeout for downloading the latest content as zip (#34045) Remove the default timeout as it's too low and a big footgun. GitOrigin-RevId: 42e26a2a288ad3e38252bc98b909a4bc8b10f70c --- services/history-v1/api/controllers/projects.js | 3 ++- services/history-v1/storage/lib/project_archive.js | 5 ++--- .../test/acceptance/js/storage/project_archive.test.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/services/history-v1/api/controllers/projects.js b/services/history-v1/api/controllers/projects.js index 040970faea..2b79beffc6 100644 --- a/services/history-v1/api/controllers/projects.js +++ b/services/history-v1/api/controllers/projects.js @@ -290,7 +290,8 @@ async function getZip(req, res, next) { async function streamZip(snapshot, blobStore, res) { await withTmpDir('get-zip-', async tmpDir => { const tmpFilename = Path.join(tmpDir, 'project.zip') - const archive = new ProjectArchive(snapshot) + const zipTimeoutMs = parseInt(config.get('zipStore.zipTimeoutMs'), 10) + const archive = new ProjectArchive(snapshot, zipTimeoutMs) await archive.writeZip(blobStore, tmpFilename) res.set('Content-Type', 'application/octet-stream') res.set('Content-Disposition', 'attachment; filename=project.zip') diff --git a/services/history-v1/storage/lib/project_archive.js b/services/history-v1/storage/lib/project_archive.js index 8a8e93f1c9..bc06a2d398 100644 --- a/services/history-v1/storage/lib/project_archive.js +++ b/services/history-v1/storage/lib/project_archive.js @@ -21,7 +21,6 @@ const assert = require('./assert') // The maximum safe concurrency appears to be 1. // https://github.com/overleaf/issues/issues/1909 const FETCH_CONCURRENCY = 1 // number of files to fetch at once -const DEFAULT_ZIP_TIMEOUT = 25000 // ms class DownloadError extends OError { constructor(hash) { @@ -49,14 +48,14 @@ class ProjectArchive { /** * @constructor * @param {Snapshot} snapshot - * @param {number} [timeout] in ms + * @param {number} timeout in ms * @classdesc * Writes the project snapshot to a zip file. */ constructor(snapshot, timeout) { assert.instance(snapshot, Snapshot) this.snapshot = snapshot - this.timeout = timeout || DEFAULT_ZIP_TIMEOUT + this.timeout = timeout } /** diff --git a/services/history-v1/test/acceptance/js/storage/project_archive.test.js b/services/history-v1/test/acceptance/js/storage/project_archive.test.js index d9112b1b67..c263ee3401 100644 --- a/services/history-v1/test/acceptance/js/storage/project_archive.test.js +++ b/services/history-v1/test/acceptance/js/storage/project_archive.test.js @@ -62,7 +62,7 @@ describe('ProjectArchive', function () { it('archives a small snapshot with binary and text data', function () { return makeMixedTestSnapshot(1) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -83,7 +83,7 @@ describe('ProjectArchive', function () { it('archives a larger snapshot with binary and text data', function () { return makeMixedTestSnapshot(10) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -102,7 +102,7 @@ describe('ProjectArchive', function () { return blobStore .putString('') .then(() => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -134,7 +134,7 @@ describe('ProjectArchive', function () { it('rejects with the error', function () { return makeMixedTestSnapshot(1) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => { @@ -169,7 +169,7 @@ describe('ProjectArchive', function () { it('rejects with the error', function () { return makeMixedTestSnapshot(1) .then(snapshot => { - const projectArchive = new ProjectArchive(snapshot) + const projectArchive = new ProjectArchive(snapshot, 25_000) return projectArchive.writeZip(blobStore, zipFilePath) }) .then(() => {