samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.85k stars 95 forks source link

Throwing ReferenceError before handling it #1030

Closed hikinine closed 1 month ago

hikinine commented 1 month ago

I've already fixed my issue by upgrading node version from 18 to 20.16. Anyway, it took a while to figure out what was going on. Checking the "File" instance with typeof throws ReferenceError before checking for undefined and returning the properly message.

Just reporting in case anyone else has the same issue

Exception: ReferenceError: File is not defined
    at /app/node_modules/@nestia/core/lib/decorators/TypedFormData.js:185:38
    at /app/node_modules/@nestia/core/lib/decorators/TypedFormData.js:135:29
    at Generator.next (<anonymous>)
    at fulfilled (/app/node_modules/@nestia/core/lib/decorators/TypedFormData.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  method: 'POST',
  path: '/sales/lead/create-prospection-list'
}

https://github.com/samchon/nestia/blob/master/packages/core/src/decorators/TypedFormData.ts image

ReferenceError https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError

samchon commented 1 month ago

In the JavaScript, when typeof X statement be declared to the non-existing instance, its return value is undefined.

You'd just used older version of @nestia/core which has not checked the existence of File class by the typeof X statement.

Just upgrade @nestia/core to latest, then the problem be fixed.