Payload too large
I am getting a payload too large error, directing me to this line:
const response = await api.post(operationRoute.path, superjsonArgs)
How can adjust the max payload size for uploads?
26 Replies
Hi @prof_mark. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain information on how to adjust the max payload size for uploads in Wasp. I recommend checking the Wasp documentation or reaching out to the Wasp community for further assistance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @prof_mark, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
I've tried following the directions here: https://wasp-lang.dev/docs/advanced/middleware-config#default-middleware-definitions
I now have in my serverSetup.ts file:
but I now get an error:
Any ideas @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
The error message indicates that the
setup
function is not being exported from your serverSetup.ts
file. The setup
function is required by Wasp and is expected to be exported from your server setup file.
In your serverSetup.ts
file, you should have something like this:
The setup
function is expected to be an async function and will be awaited before the server starts accepting any requests. It allows you to do any custom setup, e.g. setting up additional database/websockets or starting cron/scheduled jobs. You can read more about it in the Wasp documentation (https://wasp-lang.dev/docs/project/server-config#setupfn-extimport).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @prof_mark, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?this didnt work. i am giving up for now and hopefully someonw has an idea
Hey @prof_mark
You used a named export in serverSetup.ts, but imported it using a default import in wasp. You should either use a default export in both files, or a named export in both files.
With the code you showed here, the import in main.wasp must look like
import { serverMiddleWareFn } from '@src/serverSetup.ts
(notice the curly braces).
But more importantly, what are you uploading that exceeds the payload limit?Awesome thank you!
Wohooo @prof_mark, you just became a Waspeteer level 1!
Was trying to send a 512x512 base 64 encoded image to open AI for their vision model. So really just needed to pass through. Ended up switching to sending the URL since I'm uploading the images to s3 anyway
Ok, good choice!
Yeah, that's pretty big for a post request 😅
Hi @sodic @miho @martinsos I implented this according to the instructions however I'm encountering an error
TypeError: middlewareConfig.set is not a function
what did I missUff no idea, it is looking good to me @mm ! Which version of Wasp are you using? What does TS / LSP say, what are the functions availble on that object?
You'll need to share your Wasp file as well. I'd recommend using code blocks for sharing code: https://www.markdownguide.org/extended-syntax/#fenced-code-blocks
Extended Syntax | Markdown Guide
Advanced features that build on the basic Markdown syntax.
Hi @martinsos @miho do I need to provide the whole wasp file? Here are the code snippets
wasp file
server setup
Error
@mm I've done the same thing as you did and it worked for me. Where is the
serverSetup.ts
file located? Is it named like that: serverSetup.ts
?Hi @miho it is located in app/src and yes named exactly like that
it really says middlewareconfig.set is not a function
does the node version matter? I'm using v20
did you not get a console error? saying middleware config set not a
We area lso using node 20!
Hm weird that it works for Miho and not for you.
Can you maybe check, in package-lock.json, what is the version of express.js that your app is using?
Finally, is tehre any chance you could share the project with us? Maybe you could makea bare-bones project that has just that tricky part and then put it in public repo on github and share with us?
says here express
~4.18.1
. Yes I could try that@miho is it possible that this is somehow related with our update of express? Or that sometihng changes on the express side? But 4.18.1 should be fine, right?
express
is not in the code path for this feature - it shouldn't matter. It's just some TS types that we wrote and then users use.
@mm are things still not working for you?Hi @miho not yet. haven't tried the bare-bones yet. busy with something else. will update you guys once I tried that one
Hi @miho @martinsos found the problem. I just removed the setupFn since I'm not using it. What customizations can I do with setupFn btw.
Wait what was the problem? You were missing a declaration in Wasp?
the problem was I added
setupFn: import {serverMiddlewareFn} from "@src/serverSetup",
while importing the same function as the middlewareConfigFn that's why middlewareConfigFn was not detected. it's being executed from setupFn
I guessOh, so because you used it in two places?
Found it - it's not because it was used in two places, it's because the middleware fn was set as the setup fn.
SetupFn is imported and then called e.g.
serverMiddlewareFn()
like this. But nothing is passed in and the middlewareConfig
is undefined
and then you get the error:Ok, nice!