-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
📜 Description
Right now, Novu API can only accept request size 100 KB at most. A simple trigger event is around 70 KB, but with attachments
, it can easily exceed 100 KB, leading to code 413 Payload too large.
Not a NestJS expert, but I think the code below does not initialize Nest App with correct bodyParser
and rawBody
configuration, leading to an unexpected behavior.
novu/apps/api/src/bootstrap.ts
Line 63 in 0269ddc
bodyParser: false, |
Quick NestJS reference: https://docs.nestjs.com/faq/raw-body#body-parser-size-limit
👟 Reproduction steps
Use a simple trigger event with attachments.
await novu.trigger("workflow-id", {
to: "subscriber-id",
payload: {
// Practically total file size is limit around 30 KB, because the request itself is around 70 KB.
attachments: [bufferData]
}
})
👍 Expected behavior
There are 2 possible ways.
- Allow a safe, fixed limit for an API request size.
- Expose a configuration (e.g., via environment variable), so developers can customize limits on their own. Why? Each notification/message provider has their own size limit, so developers can set the limit at their own judgment. For example, Gmail is capped at 25 MB per request.
👎 Actual Behavior with Screenshots
Here is a sample error emitted by Novu API service.
{
"level": 50,
"time": 1725558183913,
"pid": 18,
"serviceName": "@novu/api",
"serviceVersion": "0.24.0",
"platform": "Docker",
"tenant": "OS",
"context": "ExceptionsHandler",
"err": {
"type": "Error",
"message": "request entity too large",
"stack": "PayloadTooLargeError: request entity too large\n
at readStream (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/raw-body/index.js:163:17)\n
at getRawBody (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/raw-body/index.js:116:12)\n
at read (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/body-parser/lib/read.js:79:3)\n
at jsonParser (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/body-parser/lib/types/json.js:138:5)\n
at Layer.handle [as handle_request] (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)\n
at trim_prefix (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:328:13)\n
at /usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:286:9\n
at Function.process_params (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:346:12)\n
at next (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:280:10)\n
at initialize (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/passport/lib/middleware/initialize.js:98:5)\n
at Layer.handle [as handle_request] (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)\n
at trim_prefix (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:328:13)\n
at /usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:286:9\n
at Function.process_params (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:346:12)\n
at next (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:280:10)\n
at cors (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/cors/lib/index.js:188:7)"
},
"msg": "request entity too large"
}
Novu version
Self-host, Docker, v0.24.0
npm version
NA (using the official v0.24.0 images)
node version
NA (using the official v0.24.0 images)
📃 Provide any additional context for the Bug.
No response
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn't find a similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to submit PR?
Yes I am willing to submit a PR!