-
Notifications
You must be signed in to change notification settings - Fork 937
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
Angular SSR 17 in Firebase : listen EADDRINUSE: address already in use :::8080 #6651
Comments
I have the same problem, I have published a repo with the minimum to recreate the SSR problem with angular 17: https://github.com/hittten/angularSSR17 Clone & Setup:git clone https://github.com/hittten/angularSSR17
npm install
npx firebase init hosting Logs:
Deploy to firebase hosting with SSR function
Server logs:
{
"textPayload": "The request failed because either the HTTP response was malformed or connection to the instance had an error. Additional troubleshooting documentation can be found at: https://cloud.google.com/run/docs/troubleshooting#malformed-response-or-connection-error",
"insertId": "659475b700062cb90f40d1e3",
"httpRequest": {
"requestMethod": "GET",
"requestUrl": "https://fh-8d3e45905df6630b---ssrfirebase-project-ou4f5ridea-ew.a.run.app/home",
"requestSize": "1456",
"status": 503,
"responseSize": "896",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"remoteIp": "xx.xx.xx.xx",
"serverIp": "xx.xx.xx.xx",
"latency": "0.003751506s",
"protocol": "HTTP/1.1"
},
"resource": {
"type": "cloud_run_revision",
"labels": {
"revision_name": "ssrfirebase-project-00049-suv",
"service_name": "ssrfirebase-project",
"location": "europe-west1",
"configuration_name": "ssrfirebase-project",
"project_id": "firebase-project"
}
},
"timestamp": "2024-01-02T20:44:39.398780Z",
"severity": "ERROR",
"labels": {
"instanceId": "0087599d42b9441d6d09db1939ddd4cf4272e2926a4f28f80a4a7435e09c496814eec2631eed5c4f41d11da415f43dbdd4584eebf9300d2775bc6e376358218de7",
"goog-managed-by": "cloudfunctions"
},
"logName": "projects/firebase-project/logs/run.googleapis.com%2Frequests",
"trace": "projects/firebase-project/traces/2cbddcb349eb67f0b870211ea2050942",
"receiveTimestamp": "2024-01-02T20:44:39.688582619Z",
"spanId": "15678518055140550732"
} Infobasically I have created a project like this: npx @angular/cli@17.0.8 new angularSSR17 --ssr --routing --scss --skip-tests
cd angularSSR17
npm i -D firebase-tools@13.0.2
ng g c pages/homePage
ng g c pages/aboutPage
ng g c pages/notFoundPage I also disable pre-render in angular.json: {
"scripts": [],
"server": "src/main.server.ts",
"prerender": false,
"ssr": {
"entry": "server.ts"
}
} and I have done the settings of the routes for lazy load. I have not installed @angular/fire because it is not necessary to recreate the SSR error. ng version
firebase-tools version:
|
Hi @hittten, I discovered a workaround that can be applied to the code of an Angular application.
I don't know what exactly is the root cause, but as I mentioned it looks like |
Getting the same error:
|
@9kubczas4 Thanks for information. This works well! Add info: If you deploy index.html, Functions will not work and must be IGNORED. {
"source": ".",
"frameworksBackend": {
"region": "asia-east1"
},
"ignore": [
+ "index.html", |
@rdlabo thanks. Removing this process.env['NG_SSR_PORT'] worked But will this be fixed in future releases in angular |
Thank you for your comment, but in which file can I find it? {
|
Thank you for your comment, but in which file can I find it? to make an addition |
Reserved environment variables are listed here: https://firebase.google.com/docs/functions/config-env?gen=2nd#reserved-names |
// In cloud functions bootstrap.js
const app = import(`./dist/project/server/server.mjs`).then(server => server.app());
exports.handle = (req, res) => app.then(it => it(req, res)); It appears that the run() function generated by Angular CLI is unnecessary. I use an firebase instance in my backend, it seems to execute firebase initializeApp() twice, leading to an error. |
@9kubczas4 your workaround works perfectly. Any update about this? this issue doesn't happen in angular 16. |
Same problem here. Any news ? |
Rename the SSR port env variable to SSR_PORT. It could help to resolve this firebase issue: firebase/firebase-tools#6651 (comment), cause PORT is reserved environment variable: https://firebase.google.com/docs/functions/config-env?gen=2nd#reserved-names.
Please for now try to apply this workaround for Angular 17: #6651 (comment). I created a fix in |
Rename the SSR port env variable to SSR_PORT. It could help to resolve this firebase issue: firebase/firebase-tools#6651 (comment), cause PORT is reserved environment variable: https://firebase.google.com/docs/functions/config-env?gen=2nd#reserved-names.
Rename the SSR port env variable to SSR_PORT. It could help to resolve this firebase issue: firebase/firebase-tools#6651 (comment), cause PORT is reserved environment variable: https://firebase.google.com/docs/functions/config-env?gen=2nd#reserved-names. (cherry picked from commit 950a445)
[REQUIRED] Environment info
firebase-tools: 13.0.2
Platform: Windows, Linux
[REQUIRED] Test case
I deploy a fully workable version from the emulator in Firebase Functions of the Angular SSR application.
[REQUIRED] Steps to reproduce
During Local build I have next warning
[REQUIRED] Expected behavior
Should work exactly as in the emulator.
[REQUIRED] Actual behavior
SSR Page returns: Service Unavailable
Logs
The text was updated successfully, but these errors were encountered: