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

Failed to load static file for page: /qa/opportunities ENOENT: no such file or directory, open '/var/task/.next/server/pages/qa/opportunities.html' #366

Closed
mfrangakis opened this issue Feb 20, 2024 · 8 comments

Comments

@mfrangakis
Copy link

mfrangakis commented Feb 20, 2024

Attempting to directly access some paths returns a 500 Internal Server Error, with the error Failed to load static file for page: /qa/opportunities ENOENT: no such file or directory, open '/var/task/.next/server/pages/qa/opportunities.html'

The example above would normally be accessible at /qa/opportunities, and it is accessible without issue in my development environment (localhost:3000/qa/opportunities).

Notably, this issue only occurs on the deployed stage if one types the URL into the browser (or refreshes the page). If you navigate from a <Link /> component provided by Next.js, then the issue does not occur and the page can be accessed.

Looking at the output of the open-next command, the open-next\server\.next folder is missing the html files for most of the routes:
image

The above folders are empty as you can see; when in reality, there are quite a few routes in them. To illustrate, compared this to the output of just running the standard Next build command; the .next folder has all the html files I expected (including opportunities):
image

Note that the open-next cache does appear to have the right files too:
image

Other routes are redacted above for confidentiality reasons.

Environment
Next.js 14.1.0
OpenNext 2.3.6
Deployed via SST to the AWS af-south-1 region

@mfrangakis
Copy link
Author

Looking through the open-next codebase, I can see that these html files are removed purposely as they are static, and are to be served by the cache. They are indeed cached, as from the 3rd screenshot in the original post. Is this an issue with SST then, that the cache is not being properly served?

@conico974
Copy link
Collaborator

Are you using getStaticProps for this route ? ISR ?
Are you building on windows ?

@mfrangakis
Copy link
Author

mfrangakis commented Feb 20, 2024

Nope, not using either getStaticProps, ISR or getServerSideProps. I use client-side fetching with SWR.
Note that this same issue occurs on all the other "cached" routes as well.
Sorry, forgot to mention the build environment - Windows 11 22H2.

@khuezy
Copy link
Collaborator

khuezy commented Feb 20, 2024

I have a feeling this is a windows path issue (nextjs bug.) Can you try building in WSL?

@conico974
Copy link
Collaborator

It's definitely an issue with windows.
There is several issues here (next has some issue with windows path, and i'm pretty sure the open-next plugins does not apply properly on windows as well)
If the plugin don't work it explains why it tries to load the file using the filesystem cache handler instead our own.

@mfrangakis
Copy link
Author

Sorry for the delay - needed to install and configure WSL with node, AWS credentials, etc.

Building and deploying in WSL resulted in routes that now work as expected: /qa/opportunities does not return a 500 Internal server error but loads properly. Thanks for the help!

Where does this leave us with the Windows path handling issue? Is it something that could be looked at? Building in WSL is not a problem (albeit a lot slower), but given that my environment is Windows, it would be more convenient to have that option.

@conico974
Copy link
Collaborator

At the moment i don't think we should put too much effort into windows support for a couple of reasons:

  • It works on WSL
  • There is issue in next itself, so even if we fix things here, people might still experience trouble (and they will potentially be a lot harder to identify)
  • V3 is near, and it includes a big refactor of the code as well as a lot of changes to the plugin system. It probably make more sense to wait for V3 to start working on fix for windows

Personally i won't work on windows support (i don't have a good windows machine), but maybe in the future someone will be willing to work on this

@conico974
Copy link
Collaborator

I'll close all the windows related issue in favor of #385

@conico974 conico974 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants