Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Function body parsing is breaking our body parsing and prevent any request with body to returns #1385

Open
255kb opened this issue May 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@255kb
Copy link
Member

255kb commented May 3, 2024

Describe the bug

When using @mockoon/serverless with Firebase Functions, the body is already parsed which doesn't trigger the 'data' event. Our body parser is hanging, waiting for a 'data' event that is never coming, and thus the whole function is hanging up.
This happens every time there is a body with a parseable Content-Type (no matter the method).

Steps to Reproduce

Use the minimal setup (see serverless repo) and send a body to a POST route for example.

mock.json

Call POST /test with a Content-Type: application/json header and a body.

Solution

Either add a disableBodyParsing option to the server (and a corresponding CLI flag/serverless param), or update the body parser to automatically detect that the body was already parsed (maybe a better option).

Sources:
https://stackoverflow.com/questions/63968953/why-do-i-get-a-502-gateway-error-from-nextjs-app-hosted-on-firebase-for-post-r/63975702#63975702
https://stackoverflow.com/questions/58237305/post-request-hangs-timeout-when-trying-to-parse-request-body-running-koa-on-f
https://dev.to/3imed_jaberi/koa-bodyparser-with-firebase-cloud-functions-4ogk

Mockoon version:

all

OS / OS version:

all

@255kb 255kb added the bug Something isn't working label May 3, 2024
@255kb 255kb self-assigned this May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To do (planned)
Development

No branches or pull requests

1 participant