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

SImpleBodyParser doesn't handle x-www-form-urlencoded properly #1277

Closed
rendomnet opened this issue May 12, 2019 · 1 comment
Closed

SImpleBodyParser doesn't handle x-www-form-urlencoded properly #1277

rendomnet opened this issue May 12, 2019 · 1 comment

Comments

@rendomnet
Copy link

rendomnet commented May 12, 2019

UPDATE: - Just tested on 6.5.0 and there is no such bug. But on 6.9.2 I have this error
UPDATE2: - Just tested on 6.8.0 and there is no such bug. But on 6.9.2 I have this error

Function onRequest gives error when receiving data on local system and no error when deployed.

I have system which was working no problem but then I updated my firebase-tools.
And now I cant test onRequest functions with my postman. When I send any data to it like
image
I have error UnhandledPromiseRejectionWarning.
But if I deploy this function and send this request to deployed function then there is no error.

[REQUIRED] Environment info

**firebase-tools: 5.9.2

**Platform: macOs

[REQUIRED] Test case

const functions = require('firebase-functions');

exports.helloWorld = functions.https.onRequest((request, response) => {
  console.log("Body:",	JSON.stringify(request.body))
  response.send("Hello from Firebase!");
});

[REQUIRED] Steps to reproduce

firebase serve --only functions
postman send post request with Content-Type: application/x-www-form-urlencoded {name: john}

[REQUIRED] Expected behavior

print Body: name: john
print Hello from Firebase!

[REQUIRED] Actual behavior

(node:8692) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token a in JSON at position 1
    at JSON.parse (<anonymous>)
    at FunctionsEmulator.<anonymous> (....nvm/versions/node/v8.11.1/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:80:46)
    at Generator.next (<anonymous>)
    at ....nvm/versions/node/v8.11.1/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (....nvm/versions/node/v8.11.1/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:3:12)
    at handler (....nvm/versions/node/v8.11.1/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:75:43)
    at Layer.handle [as handle_request] (....nvm/versions/node/v8.11.1/lib/node_modules/firebase-tools/node_modules/express/lib/router/layer.js:95:5)
    at next (....nvm/versions/node/v8.11.1/lib/node_modules/firebase-tools/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (....nvm/versions/node/v8.11.1/lib/node_modules/firebase-tools/node_modules/express/lib/router/route.js:112:3)
(node:8692) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8692) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@rendomnet rendomnet changed the title function onRequest gives error when sending data on local system and no error when deployed function onRequest gives error when receiving data on local system and no error when deployed May 13, 2019
@rendomnet rendomnet changed the title function onRequest gives error when receiving data on local system and no error when deployed [v6.9.2]function onRequest error when receiving data on local system. When deployed not bug and on 6.8.0 NO bug May 13, 2019
@abeisgoat abeisgoat changed the title [v6.9.2]function onRequest error when receiving data on local system. When deployed not bug and on 6.8.0 NO bug SImpleBodyParser doesn't handle x-www-form-urlencoded properly May 13, 2019
@abeisgoat abeisgoat self-assigned this May 13, 2019
abeisgoat added a commit that referenced this issue May 13, 2019
abeisgoat added a commit that referenced this issue May 13, 2019
abeisgoat added a commit that referenced this issue May 14, 2019
@abeisgoat
Copy link
Contributor

Fix is merged in, please re-open if you're still experiencing this once 6.9.3 is out.

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

No branches or pull requests

2 participants