solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[Bug]: Firebase SSR is not working

Open rcannood opened this issue 1 year ago • 3 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Current behavior 😯

Note: I'm not sure whether this issue should be posted here or in the vinxi. I will start my posting it here, but if the issue is related to vinxi, I will repost there.

When I deploy an SSR SolidStart application to Firebase, it seems the server returns http status code 500's for very simple requests.

For example, this component does not work when deployed to Firebase, but it does when the PRESET=vercel or PRESET=node-server is used:

import { createResource, createSignal, Match, Switch } from "solid-js";
function fetchServerResource(): Promise<string> {
  "use server";
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve("Hello from the server!");
    }, 1000);
  });
}
export default function SSRLabel() {
  const [data] = createResource<string>(fetchServerResource);
  return (
    <Switch>
      <Match when={data.loading}>Loading...</Match>
      <Match when={data.error}>Error: {data.error}</Match>
      <Match when={data()}>{data()}</Match>
    </Switch>
  );
}

I'd appreciate any input on what is going wrong here, or why the application is not working as intended.

I created a small project to help me troubleshoot the issue: rcannood/solid-project.


Locally (pnpm run dev), the application looks like this:

Screenshot from 2024-10-22 10-32-13

When I visit the application hosted on Firebase ( https://solid-project-18cb3.web.app/ ), I get the following:

Screenshot from 2024-10-22 10-33-22

For good measure, I also deployed the application to Vercel, where everything does work ( https://solid-project-ncfv9j2yb-data-intuitive.vercel.app/ ):

Screenshot from 2024-10-22 10-34-34

Expected behavior 🤔

I'm expecting the Firebase-deployed application to also say "Hello from the server!".

Steps to reproduce 🕹

I created a minimum reproducible example:

  1. https://github.com/rcannood/solid-project/commit/33460f02147eea9fa72470da750680a1962d11fd: I set up a SolidStart project
  2. https://github.com/rcannood/solid-project/commit/8f7c55f98dbab12a3e6726c2d1c9391793f1eec8: I enabled SSR in the app.config.ts and set up my Firebase project
  3. https://github.com/rcannood/solid-project/commit/dc6341a4b16abe73da126138234a89a3ca6a6dde: I added a component which fetches data from the server via createResource and "use server"
  4. I deployed the application to Firebase with PRESET=firebase vinxi build and npx firebase-tools deploy

Context 🔦

No response

Your environment 🌎

No response

rcannood avatar Oct 22 '24 08:10 rcannood

I've never tried Firebase before hosting before. I understand it the basic example works but it fails as soon as you try to use server functions?

Is there anyway of getting the error logs from the server? I can see when I can get a chance to sign up and take a look at it but error might guide us to the nature of the problem.

ryansolid avatar Oct 31 '24 22:10 ryansolid

I understand it the basic example works but it fails as soon as you try to use server functions?

Indeed!

Is there anyway of getting the error logs from the server?

Looking through the logs, I see:

[nitro] [request error] [unhandled] "[object Object]" is not valid JSON
  at JSON.parse (<anonymous>)  
  at parseJSONFromBytes (node:internal/deps/undici/undici:5489:19)  
  at successSteps (node:internal/deps/undici/undici:5470:27)  
  at fullyReadBody (node:internal/deps/undici/undici:4381:9)  
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async consumeBody (node:internal/deps/undici/undici:5479:7)  
  at async Object.Kr [as handler] (./chunks/runtime.mjs:5836:45257)  
  at async ./chunks/runtime.mjs:3076:19  
  at async Object.callAsync (./chunks/runtime.mjs:5453:16)  
  at async toNodeHandle (./chunks/runtime.mjs:3347:7)

Happy to give you access to the Google Project and GitHub repository, if that helps :)

rcannood avatar Nov 01 '24 08:11 rcannood

Maybe just a quick question -- based on the information above, would you be able to make out whether this issue should be posted here in a different repository?

Thanks @ryansolid !

rcannood avatar Nov 04 '24 12:11 rcannood