From 22531969f64aa66c14a1f5103bdd52b4e36396ea Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Mon, 16 Oct 2023 11:38:15 +0200 Subject: [PATCH] Merge pull request #15080 from overleaf/msm-configurable-upload-timeout [web] Add configurable project upload timeout GitOrigin-RevId: da26d7edbce9169c92cc3bc8746cb42e5c0e4919 --- services/web/app/src/infrastructure/ExpressLocals.js | 1 + services/web/config/settings.defaults.js | 4 ++++ .../components/new-project-button/upload-project-modal.tsx | 6 ++++-- services/web/frontend/stories/decorators/scope.tsx | 1 + services/web/types/exposed-settings.ts | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index e03e4d5c3a..6f985355b5 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -393,6 +393,7 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) { emailConfirmationDisabled: Settings.emailConfirmationDisabled, maxEntitiesPerProject: Settings.maxEntitiesPerProject, maxUploadSize: Settings.maxUploadSize, + projectUploadTimeout: Settings.projectUploadTimeout, recaptchaSiteKey: Settings.recaptcha?.siteKey, recaptchaSiteKeyV3: Settings.recaptcha?.siteKeyV3, recaptchaDisabled: Settings.recaptcha?.disabled, diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js index 42ed4dc4d7..7e6d3d935a 100644 --- a/services/web/config/settings.defaults.js +++ b/services/web/config/settings.defaults.js @@ -306,6 +306,10 @@ module.exports = { maxEntitiesPerProject: 2000, + projectUploadTimeout: parseInt( + process.env.PROJECT_UPLOAD_TIMEOUT || '120000', + 10 + ), maxUploadSize: 50 * 1024 * 1024, // 50 MB multerOptions: { preservePath: process.env.MULTER_PRESERVE_PATH, diff --git a/services/web/frontend/js/features/project-list/components/new-project-button/upload-project-modal.tsx b/services/web/frontend/js/features/project-list/components/new-project-button/upload-project-modal.tsx index 0108ca97c7..f02c56dc3f 100644 --- a/services/web/frontend/js/features/project-list/components/new-project-button/upload-project-modal.tsx +++ b/services/web/frontend/js/features/project-list/components/new-project-button/upload-project-modal.tsx @@ -22,7 +22,9 @@ type UploadProjectModalProps = { function UploadProjectModal({ onHide }: UploadProjectModalProps) { const { t } = useTranslation() - const { maxUploadSize } = getMeta('ol-ExposedSettings') as ExposedSettings + const { maxUploadSize, projectUploadTimeout } = getMeta( + 'ol-ExposedSettings' + ) as ExposedSettings const [ableToUpload, setAbleToUpload] = useState(false) const location = useLocation() @@ -42,7 +44,7 @@ function UploadProjectModal({ onHide }: UploadProjectModalProps) { }, limit: 1, fieldName: 'qqfile', // "qqfile" is needed for our express multer middleware - timeout: 120000, + timeout: projectUploadTimeout, }) .on('file-added', () => { // this function can be invoked multiple times depending on maxNumberOfFiles diff --git a/services/web/frontend/stories/decorators/scope.tsx b/services/web/frontend/stories/decorators/scope.tsx index a9b67f9dd1..17afd1d0a7 100644 --- a/services/web/frontend/stories/decorators/scope.tsx +++ b/services/web/frontend/stories/decorators/scope.tsx @@ -188,6 +188,7 @@ const initialize = () => { ], editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'], validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'], + projectUploadTimeout: 12000, } window.project_id = project._id diff --git a/services/web/types/exposed-settings.ts b/services/web/types/exposed-settings.ts index 3c09cf14aa..474bf28697 100644 --- a/services/web/types/exposed-settings.ts +++ b/services/web/types/exposed-settings.ts @@ -21,6 +21,7 @@ export type ExposedSettings = { hasSamlFeature: boolean isOverleaf: boolean maxEntitiesPerProject: number + projectUploadTimeout: number maxUploadSize: number recaptchaDisabled: { invite: boolean