quarkiverse / quarkus-quinoa

Quinoa is a Quarkus extension which eases the development, the build and serving of single page apps (built with NodeJS: React, Angular, …) alongside Quarkus . It is possible to use it with a Quarkus backend in a single project
Apache License 2.0
80 stars 40 forks source link

Corrupt image assets after adding AWS Lambda extension #702

Open rrowlands opened 3 months ago

rrowlands commented 3 months ago

Hi all,

Apologies in advance, I realize this will be a weird question. At the moment I'm having issues with quarkus builds in my Angular Quinoa project where I'm able to serve up images just fine if I do an 'ng serve', but once the images get included into the quarkus build (with either 'quarkus dev' or 'quarkus build') they come out jumbled and are not able to be viewed. I've experimented a little bit with looking at the files coming from the dev server and it appears as if the binary is getting corrupted. It almost looks to me like quote characters in the binary file are being replaced with something else, since vim renders the binary as quotes in the original source image, but it renders only that binary as a question mark in the image served from quarkus dev, so the file quarkus is serving differs in its binary content but only very slightly and only very specific sections of the binary output are being slightly changed.

Just as a random shot in the dark, does this make any sort of sense to any experienced quarkus devs out there? Maybe I have turned on some sort of character escape filter for quarkus assets or something that I don't know about?

The weird thing is that whatever is happening I am able to render text assets (html, css, etc.) with zero issues. It just seems to be something specific to how images are being processed. Oh it also seems to garble up fonts as well.

I'm using the latest versions of angular (18) and quarkus/quinoa (3.11.3 / 2.3.10) and I don't have any sort of weird custom pre / post processors set up or anything weird like that (other than Lombok, but that's on the Java side).

Thanks

melloware commented 3 months ago

weird nothing that i am aware of. Can you put together a minimal reproducer?

rrowlands commented 3 months ago

The error starts happening once you add the quarkus lambda http support to the project. I reproduced it pretty easily with the following:

quarkus create app quinoa-app -x=io.quarkiverse.quinoa:quarkus-quinoa && cd quinoa-app

quarkus ext add io.quarkus:quarkus-amazon-lambda-http

wget https://assets.bonappetit.com/photos/58dbf6c8a6614f6f50816994/16:9/w_2560%2Cc_limit/20170323%2520MOB6231_FINAL_crop.jpg -O src/main/webui/public/strawberry.jpg

quarkus dev

From a web browser hit: http://localhost:8080/strawberry.jpg

Firefox returns: The image “http://localhost:8080/strawberry.jpg” cannot be displayed because it contains errors.

Chrome displays a blank page

If you perform the exact same steps but you don't import the lambda extension it works just fine.

melloware commented 3 months ago

Excellent debugging and thanks for the reproducer.

melloware commented 3 months ago

@rrowlands it looks like AWS Lambda extensions the way it is designed wreaks havoc with serving other resources see this ticket: https://github.com/quarkusio/quarkus/issues/34285

I have a feeling that issue is similar to what we are seeing.

rrowlands commented 3 months ago

I don't think it's related to the dev ui since I deployed this onto lambda (from a quarkus build) and it scrambles images just the same.

melloware commented 3 months ago

@rrowlands no i mean something with Lamdba is intercepting HTTP requests and breaking things like it does for the Dev UI. Quinoa is similar in that its "forwarding" HTTP requests etc.