Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Infinite loop in prod builds #1640

Open
2 tasks done
maxburs opened this issue Sep 29, 2024 · 6 comments
Open
2 tasks done

[Bug?]: Infinite loop in prod builds #1640

maxburs opened this issue Sep 29, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@maxburs
Copy link

maxburs commented Sep 29, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When doing a prod build, app freezes. Dev builds unaffected. Static versions of the pages appear ok, GET request responses appear missing?

Expected behavior 🤔

No response

Steps to reproduce 🕹

Reproduction here: https://deploy-preview-23--maxburson.netlify.app/
Code: https://github.com/maxburs/blog/tree/solid-start

Context 🔦

Trying to get SolidStart to statically render the GET requests on my blog. At least, I'm guessing it's related to the GET requests?

https://github.com/maxburs/blog/blob/6f705bf50a1436bc6d9040bbf1697c650d23ae92/src/routes/index.tsx#L13

const getMainRouteData = GET(async () => {
  'use server';

  return getAllPosts().map((p) => {
    const { content: _, ...rest } = p;
    return rest;
  });
});

https://github.com/maxburs/blog/blob/6f705bf50a1436bc6d9040bbf1697c650d23ae92/app.config.ts

import { defineConfig } from '@solidjs/start/config';

// https://docs.solidjs.com/solid-start/reference/entrypoints/app-config

export default defineConfig({
  ssr: true,
  // https://nitro.unjs.io/config
  // https://vinxi.vercel.app/guide/getting-started.html
  server: {
    preset: 'static',
    prerender: {
      crawlLinks: true,
      failOnError: true,
    }
  },
});

Your environment 🌎

Issue reproduces when built on an M3 Mac and on Netlify, both using Node 20
@maxburs maxburs added the bug Something isn't working label Sep 29, 2024
@lxsmnsyc
Copy link
Member

lxsmnsyc commented Sep 29, 2024

I think part of the mistake here is that there's two use server. Perhaps you don't need the use server inside GET and then fix the types in getAllPosts for it to consistently return Promise<T> because server functions always return them.

@maxburs
Copy link
Author

maxburs commented Oct 6, 2024

@lxsmnsyc Does this match what you suggested?

image

I still see the same error:

image

and then fix the types in getAllPosts for it to consistently return Promise because server functions always return them.

I'm not sure what this means. As far as I can tell, the type already consistently returns Promise<T>?

image

@maxburs
Copy link
Author

maxburs commented Oct 6, 2024

Getting rid of the second 'use server' in the 'src/lib/api.ts' seems to fix the issue. I'm not sure what I did wrong through. This is still a solid-start bug, right? I wouldn't expect an infinite loop when I incorrectly apply 'use server'.

@lxsmnsyc
Copy link
Member

lxsmnsyc commented Oct 6, 2024

I'm not sure what this means. As far as I can tell, the type already consistently returns Promise?

lib/api has a use server which means all exported functions are now server functions and all will return a Promise type, which in this case getAllPosts returns a Promise. This is why you are having an error about getAllPosts().map(...) is not a function because getAllPosts() returned a Promise.

@maxburs
Copy link
Author

maxburs commented Oct 6, 2024

I tried to create a more minimal repro, but, it fails to load for (as far as I can tell) a totally different issue: https://github.com/maxburs/solid-start-infinite-loop

  • yarn dev never loads at all (no error in cli)
  • yarn build succeeds
  • yarn build && npx serve ./.output/public also never loads

@maxburs
Copy link
Author

maxburs commented Oct 7, 2024

Last comment was slightly wrong. In the repro above, yarn dev works. yarn build && npx serve ./.output/public loads the first time it's open, freezes, and then additional attempt to open localhost:3000 freeze before the static html is rendered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants