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

Cannot deploy Next.js app with Server Side Rendering #7146

Closed
dominoFire opened this issue May 9, 2024 · 10 comments · Fixed by #7148
Closed

Cannot deploy Next.js app with Server Side Rendering #7146

dominoFire opened this issue May 9, 2024 · 10 comments · Fixed by #7148

Comments

@dominoFire
Copy link

dominoFire commented May 9, 2024

[REQUIRED] Environment info

firebase-tools:

PS C:\Users\ferag\one\two\three\four> firebase --version
13.8.1

Platform: Windows 11, node --version: v20.10.0

[REQUIRED] Test case

This happened when I was trying to deploy a next.js app, noted in https://github.com/copilotkit/copilotkit

[REQUIRED] Steps to reproduce

Create a next app with create-next-app

Add a next.js backend route. Example: src/app/route.ts, like so:

export async function POST(req: Request): Promise<Response> {
    return new Response('Hello World', { status: 200 });
}

Init firebase Hosting in the created app

firebase init

Deploy the project

firebase deploy --debug

[REQUIRED] Expected behavior

My app is deployed to Firebase

[REQUIRED] Actual behavior

The deploy fails with the following message:


Building a Cloud Function to run this application. This is needed due to:
 • Image Optimization
 • non-static component /api/route

[2024-05-09T18:25:24.695Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/propio-panel/sites/propio-panel [none]
[2024-05-09T18:25:25.324Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/propio-panel/sites/propio-panel 200
[2024-05-09T18:25:25.325Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/propio-panel/sites/propio-panel {"name":"projects/propio-panel/sites/propio-panel","defaultUrl":"https://propio-panel.web.app","type":"DEFAULT_SITE"}
[2024-05-09T18:25:25.427Z] Error: ENOENT: no such file or directory, lstat 'C:\Users\ferag\one\two\three\four\hosting\.next\C:\Users\ferag\one\two\three\four\hosting\.next\app-build-manifest.json'

Error: An unexpected error has occurred.
@google-oss-bot
Copy link
Contributor

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@dominoFire
Copy link
Author

I have seen this issue reported before: #6253

@dominoFire
Copy link
Author

Also, seen here #5158

@dominoFire
Copy link
Author

Seen similar issue here: #6435

@dominoFire
Copy link
Author

Did some debugging. This seems happening because glob function is returning absolute paths instead of relative paths that are needed later in a copying process:

glob(
"**",
{
ignore: [join("cache", "webpack", "*-development", "**"), join("cache", "eslint", "**")],
cwd: join(sourceDir, distDir),
nodir: true,
absolute: false,
realpath: IS_WINDOWS,
},
(err, matches) => {
if (err) reject(err);
resolve(matches);
},

@dominoFire
Copy link
Author

I can attempt a PR.

@aalej
Copy link
Contributor

aalej commented May 9, 2024

Hey @dominoFire, thanks for reporting this. I was able to reproduce the error you encountered. I’ll raise this to our engineering team so they can take a look. To workaround the issue, could you try deploying using firebase-tools v13.8.0?

It also looks like you may have identified the cause of the issue here, feel free to create a PR for this if you’re up for it! Contributions are always appreciated!

@jamesdaniels
Copy link
Member

@leoortizz PTAL too since you've been fighting some path fires

@dominoFire
Copy link
Author

dominoFire commented May 9, 2024

Just noticed the glob package version used here is 7., new new glob version is 10., and it behaves differently with realpath parameter.

On 7.* (in a test app) it return the full path on Windows if realpath = true
On 10.* (in a test app) it returns the relative path if realpath = true

"glob": "^7.1.2",

@leoortizz
Copy link
Member

thanks @dominoFire for reporting the issue and apologies for the inconvenience. I have a fix in #7148 and explained the reason in the PR description. As soon as that PR is merged and released this issue will be fixed.

As a workaround, please use version v13.6.1 in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants