Skip to content
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

ng test crashes on Node 14.15.2 and Node 15 #19644

Closed
1 of 15 tasks
devoto13 opened this issue Dec 17, 2020 · 3 comments · Fixed by #19646
Closed
1 of 15 tasks

ng test crashes on Node 14.15.2 and Node 15 #19644

devoto13 opened this issue Dec 17, 2020 · 3 comments · Fixed by #19646

Comments

@devoto13
Copy link
Contributor

devoto13 commented Dec 17, 2020

🐞 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?

No.

Description

Node has made a change, which was released in Node 14.15.2 and Node 15.x lines. This change caused Angular CLI Karma plugin crash (karma-runner/karma#3588) because of the behaviour change. The culprit seems to be this line. On Node 14.15.2 this code will result in a webpackReq.headers being undefined, which leads to the crash in webpack-dev-middleware down the callstack. From the Node issue it looks like change is going to be reverted in 14.x, but maybe not in 15.x. So I think it still makes sense to adjust Angular CLI code to be compatible with the future Node release.

🔬 Minimal Reproduction

  1. git clone git@github.com:devoto13/ng-test-crash.git
  2. cd ng-test-crash
  3. npm i
  4. npm test

🔥 Exception or Error

17 12 2020 16:06:15.208:ERROR [karma-server]: UnhandledRejection: Cannot read property 'range' of undefined
17 12 2020 16:06:15.211:ERROR [karma-server]: TypeError: Cannot read property 'range' of undefined
    at handleRangeHeaders (/Users/devoto13/Projects/trash/dummy/node_modules/webpack-dev-middleware/lib/util.js:131:21)
    at processRequest (/Users/devoto13/Projects/trash/dummy/node_modules/webpack-dev-middleware/lib/middleware.js:98:19)
    at ready (/Users/devoto13/Projects/trash/dummy/node_modules/webpack-dev-middleware/lib/util.js:53:12)
    at handleRequest (/Users/devoto13/Projects/trash/dummy/node_modules/webpack-dev-middleware/lib/util.js:182:5)
    at /Users/devoto13/Projects/trash/dummy/node_modules/webpack-dev-middleware/lib/middleware.js:64:7
    at new Promise ()
    at middleware (/Users/devoto13/Projects/trash/dummy/node_modules/webpack-dev-middleware/lib/middleware.js:63:12)
    at /Users/devoto13/Projects/trash/dummy/node_modules/@angular-devkit/build-angular/src/webpack/plugins/karma.js:288:13
    at call (/Users/devoto13/Projects/trash/dummy/node_modules/connect/index.js:239:7)
    at next (/Users/devoto13/Projects/trash/dummy/node_modules/connect/index.js:183:5)
    at /Users/devoto13/Projects/trash/dummy/node_modules/karma/lib/web-server.js:24:9
    at call (/Users/devoto13/Projects/trash/dummy/node_modules/connect/index.js:239:7)
    at next (/Users/devoto13/Projects/trash/dummy/node_modules/connect/index.js:183:5)
    at nullProxy (/Users/devoto13/Projects/trash/dummy/node_modules/karma/lib/middleware/proxy.js:86:52)
    at call (/Users/devoto13/Projects/trash/dummy/node_modules/connect/index.js:239:7)
    at next (/Users/devoto13/Projects/trash/dummy/node_modules/connect/index.js:183:5)

🌍 Your Environment

Angular CLI: 11.0.4
Node: 14.15.2
OS: darwin x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.4
@angular-devkit/build-angular   0.1100.4
@angular-devkit/core            11.0.4
@angular-devkit/schematics      11.0.4
@schematics/angular             11.0.4
@schematics/update              0.1100.4
rxjs                            6.6.3
typescript                      4.0.5

Anything else relevant?

@cexbrayat
Copy link
Member

👍 Awesome investigation @devoto13

As a workaround adding:


    proxies: {
      '/assets/': '/base/src/assets/'
    },

to our karma conf seems to fix the issue

@alan-agius4 The issue might be more frequent than low as some devs (like us) may build on ci using node-lts, which is broken until v14.5.3 is released.

@alan-agius4
Copy link
Collaborator

@cexbrayat, I think low is appropriate in this case. I think the percentage of users that are using the Angular CLI with Node.js version 14.15.2 compared to other Node.js versions is low.

That said, we will still be looking at resolving this.

clydin added a commit to clydin/angular-cli that referenced this issue Dec 17, 2020
… middleware

This changes the internal Angular Karma plugin's asset fallback middleware to rewrite the request URL directly instead of trying to copy the request properties.  With changes in newer Node.js versions, not all request properties may be enumerable.

Fixes: angular#19644
clydin added a commit to clydin/angular-cli that referenced this issue Dec 17, 2020
… middleware

This changes the internal Angular Karma plugin's asset fallback middleware to rewrite the request URL directly instead of trying to copy the request properties.  With changes in newer Node.js versions, not all request properties may be enumerable.

Fixes: angular#19644
alan-agius4 pushed a commit that referenced this issue Dec 18, 2020
… middleware

This changes the internal Angular Karma plugin's asset fallback middleware to rewrite the request URL directly instead of trying to copy the request properties.  With changes in newer Node.js versions, not all request properties may be enumerable.

Fixes: #19644
alan-agius4 pushed a commit that referenced this issue Dec 18, 2020
… middleware

This changes the internal Angular Karma plugin's asset fallback middleware to rewrite the request URL directly instead of trying to copy the request properties.  With changes in newer Node.js versions, not all request properties may be enumerable.

Fixes: #19644
(cherry picked from commit 0e5dab4)
@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 Jan 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants