payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
22.05k stars 1.33k forks source link

Uploading large videos. Cannot read properties of undefined (reading 'timeout': handleUpload.ts #7019

Open thijssmudde opened 3 weeks ago

thijssmudde commented 3 weeks ago

Link to reproduction

No response

Describe the Bug

I have an issue uploading videos larger than ~45 mb to Azure blob storage using the payload upload fields. The following error is shown in my console.

    err: {
      "type": "TypeError",
      "message": "Cannot read properties of undefined (reading 'timeout')",
      "stack":
          TypeError: Cannot read properties of undefined (reading 'timeout')
              at Object.handleUpload (/Users/thijssmudde/projects/eurocom/Cloud.CMS.Contento/node_modules/@payloadcms/plugin-cloud-storage/src/adapters/azure/handleUpload.ts:38:36)
              at map (/node_modules/@payloadcms/plugin-cloud-storage/src/hooks/beforeChange.ts:48:25)
              at Array.map (<anonymous>)
              at hook (/node_modules/@payloadcms/plugin-cloud-storage/src/hooks/beforeChange.ts:47:32)
              at /node_modules/payload/src/collections/operations/create.ts:185:16
              at create (/node_modules/payload/src/collections/operations/create.ts:181:5)
              at createHandler (/node_modules/payload/src/collections/requestHandlers/create.ts:26:17)
    }

In the CMS there is no error shown to the user. After saving the video the user is redirected to the detail video page. However if you click on the video link its a 404.

Cannot GET /videos/test-(1080p)-1.mp4

My file upload limit is more than enough to handle these files.

  upload: {
    limits: {
      fileSize: 100 * 1024 * 1024, // 100 MB
    },
  },

I have the following related packages:

    "@azure/storage-blob": "^12.17.0",
    "@payloadcms/bundler-webpack": "^1.0.6",
    "@payloadcms/db-mongodb": "^1.5.1",
    "@payloadcms/plugin-cloud": "^3.0.1",
    "@payloadcms/plugin-cloud-storage": "^1.1.2",
    "@payloadcms/richtext-lexical": "^0.11.1",
    "cross-env": "^7.0.3",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "payload": "^2.18.3",

To Reproduce

  1. Create a video collection and attempt to upload a large file via the CMS interface.
  2. Attempt to open the video.
image

Payload Version

2.18.3

Adapters and Plugins

@payloadcms/plugin-cloud-storage

BarrySaikSoundry commented 2 weeks ago

I found a similar issue with AWS amplify. POST objects are limited in size. For me it worked fine on localhost and then failed when deployed. I had to implement multipart uploads to S3 to work around it.