firebase / firebase/functions-samples

template-handlebars example throws "Can't set headers after they are sent."

Open
#337 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.2k
Forks
3.8k
Avg merge
3d 23h
Merged PRs (30d)
1

Description

Browser: Chrome
Browser version: 64.0.3282.186
Operating system: Ubuntu
Operating system version: 16.04

What steps will reproduce the problem:
1. Clone the `function-samples` repository
2. Navigate to the `template-handlebars` directory and follow the instructions to set up and the app and serve it locally.
3. Open a browser and attempt to load the index page.

What is the expected result?
The page loads in the browser.

What happens instead of that?
The function server throws an error:
=== Serving from '/home/david/Sync/functions-samples/template-handlebars'...

i functions: Preparing to emulate functions.
Warning: You're using Node.js v8.9.1 but Google Cloud Functions only supports v6.11.1.
i hosting: Serving hosting files from: public
✔ hosting: Local server: http://localhost:5000

✔ functions: app: http://localhost:5001/template-handlebars-9ed7b/us-central1/app
[hosting] Rewriting / to local function app
info: User function triggered, starting execution
info: Check if request is authorized with Firebase ID token
Signed-in user: undefined
info: Execution took 14 ms, user function completed successfully
127.0.0.1 - - [04/Mar/2018:09:15:06 +0000] "GET / HTTP/1.1" 404 139 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
error: _http_outgoing.js:494
throw new Error('Can\'t set headers after they are sent.');
^

Error: Can't set headers after they are sent.
at validateHeader (_http_outgoing.js:494:11)
at ServerResponse.setHeader (_http_outgoing.js:501:3)
at ServerResponse.header (/home/david/Sync/functions-samples/template-handlebars/functions/node_modules/express/lib/response.js:767:10)
at ServerResponse.send (/home/david/Sync/functions-samples/template-handlebars/functions/node_modules/express/lib/response.js:170:12)
at done (/home/david/Sync/functions-samples/template-handlebars/functions/node_modules/express/lib/response.js:1004:10)
at Immediate._onImmediate (/home/david/Sync/functions-samples/template-handlebars/functions/node_modules/express-handlebars/lib/utils.js:26:13)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
error: Function worker crashed with exit code: 1
[hosting] Rewriting / to local function app
info: Execution took 10 ms, finished with status: 'crash'

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.