tohuwabohu-io / librefit

OpenSource calorie tracker using kotlin, quarkus, postgresql, SvelteKit and OpenAPI 3
https://libre.fit/
GNU General Public License v3.0
1 stars 0 forks source link

fly.io evaluation #74

Closed tohuwabohu-io closed 2 months ago

tohuwabohu-io commented 2 months ago

Some lessons were learnt. TODO.

Deployment

The Dockerfile is needed to build an Image during fly.io deployment. Maybe the second image build can be avoided with fly deploy -i <image>, it's mentioned here: https://news.ycombinator.com/item?id=30019194

Service

Web This actually makes my head hurt. Responses from POST requests cannot be decoded in the browser. The only difference I found was:

  1. Content-Encoding is set to "gzip" -> the fly.io proxy does that automatically as mentioned here: https://community.fly.io/t/content-encoding-gzip/4000 I found no way to turn that off reliably
  2. Sometimes the Transfer-Encoding is not set
  3. Sometimes the Content-Length is not set

Example response headers (after POST on /tracker/weight/create):

headers: Headers(7) { "content-encoding" → "gzip", "content-type" → "application/json;charset=UTF-8", date → "Mon, 11 Mar 2024 13:58:54 GMT", … }
<entries>
"content-encoding": "gzip"
"content-type": "application/json;charset=UTF-8"
date: "Mon, 11 Mar 2024 13:58:54 GMT"
"fly-request-id": "01HRPWYA27YNRT1F06MMT98KWY-fra"
server: "Fly/0637d260 (2024-03-07)"
via: "1.1 fly.io, 2 fly.io"
"x-firefox-spdy": "h2"

This results in TypeError: Decoding failed. with no useful information. The response itself contains status 201 and everything looks fine in the logs. It works when testing locally both in the IDE and using docker-compose with the production-ready images. I can only reproduce it when I activate compression for application/json on quarkus.

Workaround: Only evaluate the response status code and print an error if anything went wrong. Fetch the added data with a GET request. This affects

  1. the dashboard: POST /tracker/calories/create, POST /tracker/weight/create
  2. both the calorie and weight tracker pages
  3. the TDEE wizard
tohuwabohu-io commented 2 months ago

GraalVM is not critical and will be handled in #75