Przeglądaj źródła

Merge pull request #15080 from overleaf/msm-configurable-upload-timeout

[web] Add configurable project upload timeout

GitOrigin-RevId: da26d7edbce9169c92cc3bc8746cb42e5c0e4919
Miguel Serrano 2 lat temu
rodzic
commit
22531969f6

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

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

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

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

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