karma: UnhandledRejection: Cannot read property 'range' of undefined

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.

About this issue

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

Most upvoted comments

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

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

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

image

Ok thanks. Did not know this pinned thing 😉

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

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