akauppi / GroundLevel-firebase-es

[ANCHORED] Stencil for operational web apps
https://groundlevel-sep22.web.app/
Other
23 stars 3 forks source link

Firebase serving crashes with "Cannot remove headers after they are sent to the client" #22

Closed akauppi closed 3 years ago

akauppi commented 4 years ago

When running firebase serve --only functions,hosting, things work.

When only hosting is served, the execution crashes on first refresh / load of the UI.

Näyttökuva 2020-9-1 kello 7 45 20

The same in text:

$ firebase serve --only functions,hosting
⚠  Your requested "node" version "12" doesn't match your global version "14"
i  functions: Watching "/Users/asko/Git/GroundLevel-es6-firebase-web/functions" for Cloud Functions...
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000
✔  functions[logs_v190720]: http function initialized (http://localhost:5001/vue-rollup-example/europe-west3/logs_v190720).
✔  functions[fatal_v210720]: http function initialized (http://localhost:5001/vue-rollup-example/europe-west3/fatal_v210720).
✔  functions[greet]: http function initialized (http://localhost:5001/vue-rollup-example/europe-west3/greet).
i  functions[userInfoShadow]: function ignored because the firestore emulator does not exist or is not running.
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET / HTTP/1.1" 200 3087 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET /dist/main.40f4b1b3.js HTTP/1.1" 200 1736 "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET /dist/app-7b465665.js HTTP/1.1" 200 51330 "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET /dist/tslib-42f2fcab.js HTTP/1.1" 200 5522 "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET /dist/vue-router-2da158d9.js HTTP/1.1" 200 87840 "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET /dist/bundle.css HTTP/1.1" 200 4102 "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET /dist/vue-c6d74e9b.js HTTP/1.1" 200 183172 "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:44 +0000] "GET /dist/firebase-da064bd3.js HTTP/1.1" 200 990791 "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:45 +0000] "GET /__/firebase/init.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:51 +0000] "GET /signin HTTP/1.1" 200 3087 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:38:51 +0000] "GET /__/firebase/init.js HTTP/1.1" 200 - "http://localhost:5000/signin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"

i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:17 +0000] "GET /dist/main.40f4b1b3.js.map HTTP/1.1" 200 3493 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:17 +0000] "GET /dist/tslib-42f2fcab.js.map HTTP/1.1" 200 18569 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:17 +0000] "GET /dist/app-7b465665.js.map HTTP/1.1" 200 74115 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:17 +0000] "GET /dist/vue-router-2da158d9.js.map HTTP/1.1" 200 182239 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:17 +0000] "GET /dist/vue-c6d74e9b.js.map HTTP/1.1" 200 527177 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:17 +0000] "GET /dist/firebase-da064bd3.js.map HTTP/1.1" 200 2209348 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
^CShutting down...
i  functions: Stopping Functions Emulator
asko@Asko-Macmini GroundLevel-es6-firebase-web (master) $ firebase serve --only hosting
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:48 +0000] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
Error [ERR_HTTP_HEADERS_SENT]: Cannot remove headers after they are sent to the client
    at ServerResponse.removeHeader (_http_outgoing.js:603:11)
    at Responder.handleNotModified (/usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/responder.js:138:12)
    at /usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/responder.js:100:19
    at tryCatch (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:525:12)
    at invokeCallback (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:538:13)
    at publish (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:508:7)
    at flush (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:2415:5)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

Error: An unexpected error has occurred.
i  hosting: 127.0.0.1 - - [01/Sep/2020:04:39:48 +0000] "GET /__/firebase/init.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"

It looks like an internal firebase-tools bug to me. Is it, really?

firebase-tools 8.9.2 on node 14.8.0, macOS

akauppi commented 4 years ago

Until this gets resolved, just serving functions as well...

akauppi commented 4 years ago

Happens also with --only hosting,functions if one logs out, back in:

Error [ERR_HTTP_HEADERS_SENT]: Cannot remove headers after they are sent to the client
    at ServerResponse.removeHeader (_http_outgoing.js:603:11)
    at Responder.handleNotModified (/usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/responder.js:138:12)
    at /usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/responder.js:100:19
    at tryCatch (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:525:12)
    at invokeCallback (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:538:13)
    at publish (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:508:7)
    at flush (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:2415:5)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

Error: An unexpected error has occurred.
akauppi commented 4 years ago

Reproducible with commit d5debe9114a01057d6af7d3333d5353b7309501c

akauppi commented 4 years ago

This only happens with Rollup build, but that may be because Vite serves itself.

Should study whether it's Rollup, or Firebase that is the culprit. Also, check if this happens in production, or only with npm run prod:serve.

akauppi commented 3 years ago

The renaming of public/404.html mentioned here helped.

It's just a work-around so let's keep tracking that error, and rename back once there's a solution.

akauppi commented 3 years ago

Firebase had it fixed. 🥇