Firebase-tools: Express routerjs crash with Emulator

Created on 13 May 2019  路  1Comment  路  Source: firebase/firebase-tools

[REQUIRED] Environment info



firebase-tools:
firebase-tools v6.9.2


Platform: macOS

[REQUIRED] Test case

router.post("/data", function(req, res) {
    var user_id = req.body.id;
    console.log("User data >>" + JSON.stringify(req.body.user));
    ref.child("/users/" + user_id).update(
        req.body.user
    );
    res.status(204);
    res.send("");
    return "";
});

[REQUIRED] Steps to reproduce

Just make a request to rewrite endpoint

Note:"This endpoint works on version 6.8.0"

[REQUIRED] Expected behavior

Some data from the endpoint

[REQUIRED] Actual behavior

[hosting] Rewriting /users/data to http://localhost:5001/tracer-8eafa/us-central1/app for local Function app
(node:16567) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at FunctionsEmulator.<anonymous> (/Users/Nachito/.nvm/versions/node/v8.16.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:80:46)
    at Generator.next (<anonymous>)
    at /Users/Nachito/.nvm/versions/node/v8.16.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/Nachito/.nvm/versions/node/v8.16.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:3:12)
    at handler (/Users/Nachito/.nvm/versions/node/v8.16.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulator.js:75:43)
    at Layer.handle [as handle_request] (/Users/Nachito/.nvm/versions/node/v8.16.0/lib/node_modules/firebase-tools/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/Nachito/.nvm/versions/node/v8.16.0/lib/node_modules/firebase-tools/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/Nachito/.nvm/versions/node/v8.16.0/lib/node_modules/firebase-tools/node_modules/express/lib/router/route.js:112:3)
(node:16567) 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: 2)

Most helpful comment

Dupe of #1277

>All comments

Dupe of #1277

Was this page helpful?
0 / 5 - 0 ratings