redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
16.93k stars 972 forks source link

[Docs]: Standardize and document prerendering environment variable `__REDWOOD__PRERENDERING` #10372

Open ched-dev opened 3 months ago

ched-dev commented 3 months ago

Summary and description

I recently use the process.env.__REDWOOD__PRERENDERING environment variable to check if I was within the prerendering build step but couldn't find any documentation on it. I believe it should be documented within the Environment & Variables documentation.

I think it could be standardized to drop the double underscore prefix as well.

Are you interested in working on this?

ahaywood commented 3 months ago

Hey @ched-dev Thanks for filing. Would you be interested in contributing to the docs and sharing your use case?

Tobbe commented 3 months ago

It's "private", that's why it has the double underscore prefix.

Can you explain your use case a bit more please? That way we might be able to come up with a more official way of supporting what you want to do, rather than exposing an internal implementation detail πŸ™‚

pantheredeye commented 3 months ago

FWIW, some background in this thread https://discord.com/channels/679514959968993311/1221949945280467065

I have been experiencing my prerendering hanging when I try to deploy to Railway.app. I notice it always stops right after the last prerendered page (404 page in my case). It finishes on my local machine, but not when it’s up in Railway. However, it seems my local build just ends after the last prerendered page and I would assume it to exit with some kind of success message. Is that normal?

OK I think I found the issue!

When I set the cache to use InMemoryClient during build it will successfully complete. If it's set to RedisClient during build it will hang.

I remember having this issue on Vercel a while ago but I fixed it by using the InMemoryClient during build step only. When I changed to Railway I must not have moved that over.

Now I am using process.env.REDWOODPRERENDERING === '1' to check if I am prerendering, then switching cache to use InMemoryClient instead.

Is there a different way to check if I am running a build step? The double underscores makes me feel this could change in the future.

DT offers a few different suggestions in the thread.

Tobbe commented 3 months ago

Thanks for the extra context @pantheredeye

So it seems we should first try to better understand what's going on here, and then decide what to do.

@ched-dev Would you be up for trying DT's suggestions as well, and report back any and all details you can find? Just so we get a full picture of the issue.

I would prefer it if we could fix/handle this inside the framework, so that users don't have to think about this themselves πŸ™‚ We want RW to solve these kinds of weird cases for our users! 😁