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

UnhandledRejection: Cannot read property 'range' of undefined #3588

Closed
thomasturrell opened this issue Dec 16, 2020 · 19 comments
Closed

UnhandledRejection: Cannot read property 'range' of undefined #3588

thomasturrell opened this issue Dec 16, 2020 · 19 comments

Comments

@thomasturrell
Copy link

thomasturrell commented Dec 16, 2020

Karma version 5.2.3
Node version 14.15.2

After running the tests Chrome exits and I get the following error:

ERROR [karma-server]: UnhandledRejection: Cannot read property 'range' of undefined
ERROR [karma-server]: TypeError: Cannot read property 'range' of undefined

I suspect this to be related to #3571, node version 14.15.1 works correctly.

Please let me know if I need to provide more information.

@devoto13
Copy link
Collaborator

devoto13 commented Dec 16, 2020

I don't think this issue is in Karma core. From #3571 it looks like the issue is in the @angular-devkit\build-angular plugin. I've tested with fresh @angular/cli@11 project and issue is not reproducible. Please consider below options:

  • stick with older Node version
  • upgrade to latest Angular
  • report bug to Angular CLI repository with minimal reproduction if you're also using Angular 9 as in Karma test cases breaking in node 15.1 #3571. Angular 9 is an LTS release, so they may issue a fix.
  • debug this issue further and figure out if this is a Node regression, then it should be reported to Node itself (which is likely the case given that it broke in the patch release)

In any case, there is nothing we can do on the Karma core to fix issue in the third-party plugin as we don't develop this plugin.

Happy to re-open if you provide a minimal reproduction showing that this issue is caused by the Karma core.

@johnjbarton
Copy link
Contributor

FWIW I tested locally against 14.15.1 and 14.15.2 so any issue between these versions isn't visible to our tests.

@tbprojects
Copy link

Unfortunately I have the same issue in my test project. Tests work on NodeJS 14.15.1, but fails on 14.15.2 with exception:

UnhandledRejection: Cannot read property 'range' of undefined

@johnjbarton
Copy link
Contributor

@tbprojects Open up karma/lib/server.js and find

this.log.error(`UnhandledRejection: ${error.message || String(error)}`)

Add a line above:

console.error("UnhandledRejection", error.stack || "bah!")

The message should include the stack and that will help us.

@devoto13
Copy link
Collaborator

@tbprojects Thanks! I'm able to reproduce it using your repository. For some reason it does not reproduce in my freshly-generated Angular CLI 11 project. I'll check what is different tomorrow and post back.

@wvankuipers
Copy link

@tbprojects Open up karma/lib/server.js and find

this.log.error(`UnhandledRejection: ${error.message || String(error)}`)

Add a line above:

console.error("UnhandledRejection", error.stack || "bah!")

The message should include the stack and that will help us.

UnhandledRejection TypeError: Cannot read property 'range' of undefined
    at handleRangeHeaders (/node_modules/webpack-dev-middleware/lib/util.js:131:21)
    at processRequest (/node_modules/webpack-dev-middleware/lib/middleware.js:98:19)
    at ready (/node_modules/webpack-dev-middleware/lib/util.js:53:12)
    at handleRequest (/node_modules/webpack-dev-middleware/lib/util.js:182:5)
    at /node_modules/webpack-dev-middleware/lib/middleware.js:64:7
    at new Promise (<anonymous>)
    at middleware (/node_modules/webpack-dev-middleware/lib/middleware.js:63:12)
    at /node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/karma.js:270:13
    at call (/node_modules/connect/index.js:239:7)
    at next (/node_modules/connect/index.js:183:5)
    at /node_modules/karma/lib/web-server.js:24:9
    at call (/node_modules/connect/index.js:239:7)
    at next (/node_modules/connect/index.js:183:5)
    at nullProxy (/node_modules/karma/lib/middleware/proxy.js:86:52)
    at call (/node_modules/connect/index.js:239:7)
    at next (/node_modules/connect/index.js:183:5)

@wvankuipers
Copy link

Likely caused by nodejs/node#36550

@devoto13
Copy link
Collaborator

devoto13 commented Dec 17, 2020

Thanks for the link @wvankuipers. It is indeed a change in behaviour in Node, which lead to a crash of Angular CLI (because of this line).

It looks like Node is going to revert this change in LTS line. So below is the information for people experiencing this issue:

  1. Avoid affected Node version 14.15.2. And avoid 15.x as it is unsupported by both Karma and Angular CLI at the moment.
  2. Subscribe to ng test crashes on Node 14.15.2 and Node 15 angular/angular-cli#19644 for updates on Node 15 support in regards of this issue.

@devoto13 devoto13 pinned this issue Dec 17, 2020
@devoto13 devoto13 changed the title Karma test cases breaking in node 14.15.2 UnhandledRejection: Cannot read property 'range' of undefined Dec 17, 2020
@johnjbarton johnjbarton unpinned this issue Dec 17, 2020
@devoto13
Copy link
Collaborator

devoto13 commented Dec 17, 2020

@johnjbarton I think we should keep this pinned until fix is released in the next Node version, so people can easily find it and don't open new issues about the same problem.

@johnjbarton johnjbarton pinned this issue Dec 17, 2020
@johnjbarton
Copy link
Contributor

Ok thanks. Did not know this pinned thing ;-)

@Mayur123-mg
Copy link

Mayur123-mg commented Dec 18, 2020

  • i also check with Angular CLI @11.x and node v14.15.2 test case run there is no issue in it
  • who want to use node v14.15.2 for angular please update your angular version
  • use command ng update in your angular setup

@johnjbarton
Copy link
Contributor

v 14.15.3 is released https://nodejs.org/en/download/

@rattkin
Copy link

rattkin commented Jan 7, 2021

still happening on v14.15.3

@devoto13
Copy link
Collaborator

devoto13 commented Jan 7, 2021

@rattkin I can't reproduce on Node 14.15.3 using test project from #3588 (comment). Please double check that you use the mentioned Node version and provide the minimal project producing the error if you still believe that this is a bug.

@rattkin
Copy link

rattkin commented Jan 7, 2021

@devoto13 I upgraded Triton to latest and it is fixed now. Sorry for mistake, the environment that had the problem was not on 14.15.3.
solved.

@devoto13 devoto13 unpinned this issue Jan 14, 2021
@TeaTimeForever
Copy link

Same issue appeared again starting from node v15.0.0

@devoto13
Copy link
Collaborator

@TeaTimeForever Make sure you use the Angular CLI version, where the fix is included.

image

@mx2s
Copy link

mx2s commented Mar 5, 2021

downgrading from node v15 to v14.16.0 helped, tests are working now

@myu-1987
Copy link

myu-1987 commented Jun 4, 2021

"UnhandledRejection" because Karma Runner is not compatible with Node Version 15. You have to downgrade your node version below or equal to 14.

Karma Runner Open Issue - #3571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants