Skip to content

@angular-devkit/build-angular update from 12.1.x to 12.2.x SSR fails to serve #21735

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

Closed
1 of 15 tasks
rickvandermey opened this issue Sep 9, 2021 · 7 comments · Fixed by #21739
Closed
1 of 15 tasks

Comments

@rickvandermey
Copy link

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 12.1.4

Description

When building a SSR application, and serving the SSR application, it used to work, but after the update, an error is logged during the process.

TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at /Users/Sources/angular-starterkit/dist/server/main.js:1:2701809
    at Object.66252 (/Users/Sources/angular-starterkit/dist/server/main.js:1:2815455)
    at __webpack_require__ (/Users/Sources/angular-starterkit/dist/server/main.js:1:3657752)
    at Object.42853 (/Users/Sources/angular-starterkit/dist/server/main.js:1:2904269)
    at __webpack_require__ (/Users/Sources/angular-starterkit/dist/server/main.js:1:3657752)
    at Module.25944 (/Users/Sources/angular-starterkit/dist/server/main.js:1:2908930)
    at __webpack_require__ (/Users/Sources/angular-starterkit/dist/server/main.js:1:3657752)
    at app (/Users/Sources/angular-starterkit/dist/server/main.js:1:5131921)
    at run (/Users/Sources/angular-starterkit/dist/server/main.js:1:5133175)

🔬 Minimal Reproduction

https://github.com/rickvandermey/angular-starterkit/tree/feature/update-deps

Steps:

  • npm ci
  • npm run start:ssr

🌍 Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.2.5
Node: 14.16.1
Package Manager: npm 7.21.0
OS: darwin x64

Angular: 12.2.5
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.5
@angular-devkit/build-angular   12.2.5
@angular-devkit/core            12.2.5
@angular-devkit/schematics      12.2.5
@nguniversal/express-engine     12.1.0
@schematics/angular             12.2.5
rxjs                            7.3.0
typescript                      4.3.5
webpack                         5.52.0
@alan-agius4 alan-agius4 transferred this issue from angular/angular-cli Sep 9, 2021
@alan-agius4 alan-agius4 transferred this issue from angular/universal Sep 9, 2021
@alan-agius4
Copy link
Collaborator

alan-agius4 commented Sep 9, 2021

The problem appear to be this statement.

 const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf( /*#__PURE__*/_wrapAsyncGenerator(function* () {})).prototype);

Which is the result of transforming native async/await in generators since Zone.Js cannot patch these.

https://github.com/MattiasBuelens/web-streams-polyfill/blob/d035366b4033fd0c8af092d3a6938bd9c6d5974d/src/target/es2018/stub/async-iterator-prototype.ts#L4-L5

export const AsyncIteratorPrototype: AsyncIterable<any> | undefined =
  Object.getPrototypeOf(Object.getPrototypeOf(async function* (): AsyncIterableIterator<any> {}).prototype);

@alan-agius4
Copy link
Collaborator

Looking at this more, the downlevelling of the async/await is doing the right thing and the correct output is being generated. Unfortunately, web-streams-polyfill isn't handle this case.

This should be pretty straightforward from their end to fix;

  const AsyncFnPrototype = Object.getPrototypeOf(async function* () {}).prototype;
  const AsyncIteratorPrototype = AsyncFnPrototype && Object.getPrototypeOf(AsyncFnPrototype);

@alan-agius4
Copy link
Collaborator

Closing as per above.

@krzkz94
Copy link

krzkz94 commented Oct 4, 2021

Hey @alan-agius4, are you folks going to fix this for v12? It seems to be still broken with the latest 12.2.8

@alan-agius4
Copy link
Collaborator

@krzkz94, it looks like the commit was not cherry-picked due to a conflict.

We should be addressing this in the next patch release.

@rickvandermey
Copy link
Author

Can confirm its fixed in 12.2.9

@angular-automatic-lock-bot
Copy link

This 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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants