Repository navigation
[zone.js] Node > 16.17.1: Method Promise.prototype.then called on incompatible receiver #47872
Description
Activity
Same problem with Angular 14.2.X and any node version > 16.17.1 (just tested it against current LTS node Version 18.12.0)
- changed the title
[-]Prerendering error: Method Promise.prototype.then called on incompatible receiver[/-][+]Prerendering error with Node > 16.17.1: Method Promise.prototype.then called on incompatible receiver[/+]on Oct 26, 2022 @ohois Thanks for the background info, I can confirm this!
From the looks of it, it looks like a zone.js issue. Transferring to the framework repo.
This can be replicated without universal by using the below code.
index.js
async function loadEsmModule(modulePath) { return new Function('modulePath', `return import(modulePath);`)(modulePath); } (async ()=> { require('zone.js/node'); await loadEsmModule('@angular/core'); })();
$ node index.js node:internal/per_context/primordials:440 new SafePromise((a, b) => PromisePrototypeThen(mapFn == null ? promise : mapFn(promise, i), a, b)) ^ TypeError: Method Promise.prototype.then called on incompatible receiver [object Object] at ZoneAwarePromise.then (<anonymous>) at node:internal/per_context/primordials:440:35 at new Promise (<anonymous>)This seems to be caused by nodejs/node#43728.
Following a suggestion by @JiaLiPassion I have added a temporary workaround in universal via angular/universal#2879.
Reacted by Oliver Hois and Ferdinand MalcherI can confirm that this workaround fixes this issue on my end.
I can confirm that this workaround fixes this issue on my end.
Noob question.
Facing the same issue. But don't know how to use that temporary workaround mentioned by @alan-agius4
8 remaining items
- addedP3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgent
on Nov 16, 2022 - changed the title
[-]Prerendering error with Node > 16.17.1: Method Promise.prototype.then called on incompatible receiver[/-][+][zone.js] Node > 16.17.1: Method Promise.prototype.then called on incompatible receiver[/+]on Dec 5, 2022 angular-automatic-lock-bot commented
on Mar 30, 2023 More actionsThis issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
- locked and limited conversation to collaborators
on Mar 30, 2023
Prerendering throws an error when used with a Node version > 16.17.1
🐞 Bug report
What modules are related to this issue?
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:
Error at prerendering:
This happens with Node v16.18.0 🔥 and v18.11.0 🔥. The error does not appear with Node v16.17.0 ✅ .
🌍 Your Environment