question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ECONNREFUSED 127.0.0.1:53233 when running "serve-ssr" from @nguniversal/builders

See original GitHub issue

We are using Angular Universal in production and are very happy with it. We want to work with server side rendering all the way down to our day-to-day development lifecycle and have chosen to use the @nguniversal/builders package to do that.

Unfortunately, since upgrading to Angular 10.x and @nguniversal/builders 10.x, the schematic serve-ssr from @nguniversal/builders fails with the following error:

connect ECONNREFUSED 127.0.0.1:55304

🐞 Bug report

What modules are related to this issue?

  • aspnetcore-engine
  • builders
  • common
  • express-engine
  • hapi-engine

Is this a regression?

Yes, this did not happen with Angular 9.x and @nguniversal/builders 9.x but it now happens with version 10.x.

Description

After a lot of debugging, I’ve found a curious behavior: It seems as though the node net server created by @nguniversal/builders succesfully starts to listen, but after a few seconds shuts down silently. I’ve recorded this behavior and it can be seen in this short video.

Context:

  • Right-side terminal is watching all ports being listened to locally
  • Left side terminal is the server-ssr command being executed
  • At the beginning of the build, a port is opened by node (55304)
  • After a few seconds, node stops listening on 55304 silently
  • Once the build (browser and server) succeeds, my SSR server successfully starts on 4200
  • The “builder process” now tries to connect to 55304 but it’s no longer there, thus failing the command with connect ECONNREFUSED 127.0.0.1:55304

Curiously, the command works when setting "inspect": true in the config of @nguniversal/builders (angular.json). This forces us to connect a debugger to the process though, and isn’t very developer friendly.

🔬 Minimal Reproduction

Unfortunately, I don’t have a reproduction environment.

🔥 Exception or Error


connect ECONNREFUSED 127.0.0.1:55304

🌍 Your Environment


Angular CLI: 10.1.2
Node: 12.18.2
OS: darwin x64

Angular: 10.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.2
@angular-devkit/build-angular   0.1001.2
@angular-devkit/core            10.1.2
@angular-devkit/schematics      10.1.2
@nguniversal/builders           10.1.0
@nguniversal/express-engine     10.1.0
@schematics/angular             10.1.2
@schematics/update              0.1001.2
rxjs                            6.6.3
typescript                      4.0.2

This is maybe related to https://github.com/angular/universal/issues/1796

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:18
  • Comments:22

github_iconTop GitHub Comments

14reactions
danieldanieleckicommented, Oct 7, 2020

Hey, you’re not alone. I can confirm that when upgrading Angular 8 to 10 I could face exactly same issue once trying to run with the new server-ssr schematic.

6reactions
fischermattecommented, Oct 13, 2020

This is indeed a very annoying bug: It makes local development with SSR almost impossible since one has to rebuild the full prod bundle on each change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@nguniversal/builders - npm
This command is similar to ng serve, which offers live reload during development, but uses server-side rendering. The application runs in watch ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found