Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

The emulator behaves differently than the production version with respect to the rawBody property #161

Closed
grimmen opened this issue Nov 14, 2017 · 3 comments

Comments

@grimmen
Copy link

grimmen commented Nov 14, 2017

The rawBody property of the request - it is present when I run the function deployed to the cloud, but not when I run the function locally using "firebase serve --only functions". I have tried to install @latest of both firebase-tools and firebase.

Environment details

  • OS: OSX
  • Node.js version: 6.11.1
  • npm version:
  • @google-cloud/functions-emulator version: [email protected]

Steps to reproduce

  1. Receive request with body content.
  2. Check if request.rawBody property is defined and contains the byte of the body, log result
  3. Compare running the function in emulation vs. in prod
@justinwh
Copy link

I ran into this issue as well (following these docs) and at least as of 1.0.0-beta.4 I have code working in both production and the emulator with the following workaround:

Replace the call to busboy.end(req.rawBody) with...

if (req.rawBody) {
    busboy.end(req.rawBody);
}
else {
    req.pipe(busboy);
}

It pipes the request body in the emulator, where req.rawBody doesn't exist, and uses the documented behavior in production.

@robertlevy
Copy link

This should really be fixed. The sample code @ https://cloud.google.com/functions/docs/writing/http refers req.pipe which only works in the emulator, not when deployed.

@jmdobry
Copy link
Contributor

jmdobry commented Aug 1, 2018

This should be fixed in 1.0.0-beta.5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants