Skip to content

[Suspected Bug] Handle Multipart Upload emitting errors: cannot read properties of undefined (reading 'type') #762

@Type-32

Description

@Type-32

Describe the bug
I was trying out the Nuxt Hub Multipart upload in my project (purely just copy and paste with a few tweaks to the backend API routes with all requirements fullfilled in the docs) which uses Vercel Blob and everytime I try to upload it just gives me this log on the server-side:

[19:45:43]  ERROR  [request error] [unhandled] [POST] http://localhost:3000/api/v1/test/create/Pin%20on%20%E8%B5%9B%E5%8D%9A%E6%9C%8B%E5%85%8B.pdf

 
ℹ Error: Cannot read properties of undefined (reading 'type')

 ⁃ at handleUpload (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/@vercel/blob/dist/client.js:155:21)

   150 ┃    onBeforeGenerateToken,
   151 ┃    onUploadCompleted
   152 ┃  }) {
   153 ┃    var _a, _b, _c, _d;
   154 ┃    const resolvedToken = getTokenFromOptionsOrEnv({ token });
 ❯ 155 ┃    const type = body.type;
   156 ┃    switch (type) {
   157 ┃      case "blob.generate-client-token": {
   158 ┃        const { pathname, clientPayload, multipart } = body.payload;
   159 ┃        const payload = await onBeforeGenerateToken(
   160 ┃          pathname,

 ⁃ at Object.handleMultipartUpload (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/@nuxthub/core/dist/blob/lib/drivers/vercel-blob.mjs:169:26)
 ⁃ at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
 ⁃ (async file:///D:/OD/Windows%20Defaults/Documents/WebStorm%20Projects/ap-pdf-summarizer/node_modules/h3/dist/index.mjs:2004:19)
 ⁃ at async Object.callAsync (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/unctx/dist/index.mjs:72:16)
 ⁃ at async Object.callAsync (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/unctx/dist/index.mjs:72:16)
 ⁃ at async Server.toNodeHandle (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/h3/dist/index.mjs:2296:7)

[CAUSE]
TypeError {
  stack: "Cannot read properties of undefined (reading 'type')\n" +
  'at handleUpload (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/@vercel/blob/dist/client.js:155:21)\n' +
  'at Object.handleMultipartUpload (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/@nuxthub/core/dist/blob/lib/drivers/vercel-blob.mjs:169:26)\n' +
  '    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)\n' +
  'at async file:///D:/OD/Windows%20Defaults/Documents/WebStorm%20Projects/ap-pdf-summarizer/node_modules/h3/dist/index.mjs:2004:19)\n' +
  'at async Object.callAsync (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/unctx/dist/index.mjs:72:16)\n' +
  'at async Object.callAsync (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/unctx/dist/index.mjs:72:16)\n' +
  'at async Server.toNodeHandle (D:/OD/Windows Defaults/Documents/WebStorm Projects/ap-pdf-summarizer/node_modules/h3/dist/index.mjs:2296:7)',
  message: "Cannot read properties of undefined (reading 'type')",
}

I'm using the example, but if it helps I'll attach my repo here: https://github.com/CTRL-Neo-Studios/ap-pdf-summarizer. I have my Blob read write token environment variable set.

Steps to reproduce
Steps to reproduce the behavior:

  1. Clone my project
  2. Go to http://localhost:3000/testupload
  3. Try upload any file
  4. Gives error on client and server side

Expected behavior
The file uploading logic should work. Not sure what step I did wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions