angular: [zone.js] Node > 16.17.1: Method Promise.prototype.then called on incompatible receiver

Prerendering throws an error when used with a Node version > 16.17.1

🐞 Bug report

What modules are related to this issue?

  • builders
  • common
  • express-engine

Is this a regression?

Yes, the previous version in which this bug was not present was: 14.x

🔬 Minimal Reproduction

Create a new v15 CLI workspace, add SSR and run prerendering:

npx -p @angular/cli@next ng new testproject --routing --style=css
cd testproject
npm run ng -- add @nguniversal/express-engine@next
npm run ng -- run testproject:prerender

🔥 Exception or Error

Warning directly after the start:

TypeScript compiler options "target" and "useDefineForClassFields" are set to "ES2022" and "false" respectively by the Angular CLI. To control ECMA version and features use the Browerslist configuration. For more information, see https://github.com/browserslist/browserslist

Error at prerendering:

✖ Prerendering routes to testproject/browser failed.
Method Promise.prototype.then called on incompatible receiver [object Object]

This happens with Node v16.18.0 🔥 and v18.11.0 🔥. The error does not appear with Node v16.17.0 ✅ .

🌍 Your Environment


Angular CLI: 15.0.0-rc.0
Node: 18.11.0
Package Manager: npm 8.15.1
OS: darwin arm64

Angular: 15.0.0-rc.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.0-rc.0
@angular-devkit/build-angular   15.0.0-rc.0
@angular-devkit/core            15.0.0-rc.0
@angular-devkit/schematics      15.0.0-rc.0
@nguniversal/builders           15.0.0-next.0
@nguniversal/express-engine     15.0.0-next.0
@schematics/angular             15.0.0-rc.0
rxjs                            7.5.7
typescript                      4.8.4

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@submarines-and, thanks for the reproduction. I was able to get to the bottom of this and have a PR in flight to address this issue.

https://github.com/angular/universal/pull/2910

This seems to be caused by https://github.com/nodejs/node/pull/43728.

Following a suggestion by @JiaLiPassion I have added a temporary workaround in universal via https://github.com/angular/universal/pull/2879.