QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.45k stars 1.26k forks source link

[🐞] Qwik server$ throws 500 error [Firebase deployment] #6322

Open rafalfigura opened 1 month ago

rafalfigura commented 1 month ago

Which component is affected?

Qwik Runtime

Describe the bug

I'm trying to use server$. It looks like the deserializer (https://github.com/QwikDev/qwik/blob/7ed839f4cc1aa8cba1833d811a82d8a62d5865cf/packages/qwik-city/middleware/request-handler/request-event.ts#L329) gets from request.text() an empty string ''. Which then translates to an error. From the request side it looks like the json has valid data {"_entry":"3","objs":["\u0002#s_vZ1JDpk0Fwo","tool","pexels-jang-‘s-:fallen_leaf:-2664216.jpg",["0","1","2"]]} for some reason it doesn't work.

Example code:

 //server side
  export const getSignedImageUrl = server$(async function (imageSubject: ImageSubject, imageName: string) {
    // never triggers
  });

  //executed on the client side
    const onDrop = $(async (event: Event) => {
        const files = (event.target as HTMLInputElement).files;
        for (const file of files) {
           const { filePath, url } = await uploadFile(ImageSubject.Tool, file);
        ...
    }

export async function uploadFile(subject: ImageSubject, file: File) {
    console.log(`uploading file: ${file.name}`) // triggers
    const resp= await getSignedImageUrl(ImageSubject.Tool, file.name); // returns undefined due to the error 500 
}

Reproduction

https://github.com/rafalfigura/qwik-cloud-functions-test

Steps to reproduce

To reproduce:

  1. Deploy to firebase
  2. Click the only one button
  3. Look in the network tab for 500 error from server$ function

Firebase log with error: image

Example working locally image

System Info

Locally everything works as expected. When deployed to firebase with `pnpm build, firebase deploy` it throws an error.

Additional Information

More info here: https://discord.com/channels/842438759945601056/1237142526654414919

PatrickJS commented 1 month ago

what is ImageSubject?

rafalfigura commented 1 month ago

@PatrickJS the ImageSubject is just an Enum with strings. You can take a look here: https://github.com/rafalfigura/qwik-cloud-functions-test/blob/main/src/server/types.ts I've checked and it doesn't work even when the server$ function is empty

JerryWu1234 commented 1 month ago

let me try this Bug

PatrickJS commented 1 month ago

thanks @JerryWu1234 🙏 🙌

JerryWu1234 commented 1 month ago

image

I deployed a lot of times and it failed. maybe my country has a limitation. https://github.com/firebase/firebase-tools/issues/6268 So that I can't handle this

@PatrickJS

PatrickJS commented 1 month ago

ok thanks @JerryWu1234 for trying to look into this