1

I have a firebase function that is triggered by a webhook in 3rd party application. They make a post call to my function with application/x-www-urlencoded type and there are more than 1000 parameters in their post body. 1000 is default number of params in body-parser package and when it hits the limit it throws the error.

PayloadTooLargeError: too many parameters at queryparse 
(/srv/node_modules/body-parser/lib/types/urlencoded.js:151:13) at parse 
(/srv/node_modules/body-parser/lib/types/urlencoded.js:75:9)

As far as I know, firebase function also has express and body-parser running in the background and I was wondering if there is a way to modify these parameter limits. I saw a few examples to modify these settings, however below solution did not work for firebase function since it did not modify actual body-parser running behind the firebase functions.

var bodyParser = require('body-parser');

app.use(bodyParser.urlencoded({
        extended: false,
     parameterLimit: 10000,
     limit: 1024 * 1024 * 10
}));

Any suggestions or solutions will be appreciated. Thank you.

1
  • did you find a fix ?
    – Ninja Dev
    Commented Aug 7, 2022 at 15:51

1 Answer 1

0

I don't think the behavior of the body parsing middleware can be changed in any way. There's nothing in the documentation that suggests any configuration options.

If it's possible, I suggest instead having the client POST a JSON payload instead, which can contain whatever valid JSON you want.

Another alternative might be to not use the JavaScript runtime, and try Python or Go instead using the Google Cloud deployment tools. You won't be able to use the Firebase CLI any more, but the other runtimes might have different behavior that suits your needs.

2
  • Thank you always for the answer Douglas. There's a body-parser package inside firebase-tools package, and when I changed the parameterLimits that is hard coded in that package, it worked locally. only when I deployed the function, firebase somehow run npm install internally and it did not work... anyway will try json instead of urlencoded, thanks
    – M.K. Kim
    Commented Mar 20, 2020 at 18:44
  • Turns out, you changed the way the local emulator works, not the way the cloud-hosted service works. Commented Mar 20, 2020 at 19:12

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.