question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update source-map-support to 0.5.9 to resolve issue with source maps for karma runs (ng test) in v1.7.X

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [X] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 1.7.4 Node: 8.9.4 OS: darwin x64 Angular: 5.2.4

Repro steps

When running karma tests, stack traces are hidden when running via the following, unless --source-map=false is specified, however then the line numbers are incorrect:

ng test --config karma.conf.js

The log given by the failure

Stack trace in the console running karma using Chrome:

[object ErrorEvent] thrown

Stack trace in the Chrome browser console:

Failed to load ng:///DynamicTestModule/ShiftDetailCellComponent.ngfactory.js: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. (anonymous) @ zone.js:2956 polyfills.bundle.js:10484 Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/ShiftDetailCellComponent.ngfactory.js'. at http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:2956:1 at XMLHttpRequest.proto.(anonymous function) [as send] (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:1372:1)

CORS errors due to the mapping issues.

Desired functionality

The recently released version of source-map-support now catches the CORS errors and produces the correct stack trace as one would expect. See:

https://github.com/evanw/node-source-map-support/pull/222

Mention any other details that might be useful

I’m assuming there has to be a big report on this somewhere, but I couldn’t find it. There are similar issues under other projects as people have attempted to get to the root of this issue. One of those is:

https://github.com/karma-runner/karma/issues/2852

As mentioned in my post here, I have confirmed that if I delete the bundled version of source-map-support and install the latest as a peer dependency, the issue is resolved. I’m not sure if there are any other issues that may result from a minor version bump and I haven’t ran through all of the test suite for @angular/cli to verify yet, but this one issue does appear to be resolved by the new rev.

It didn’t appear that source-map-support is still used in 6.0.X of the CLI, so not sure if this is even an issue with newer versions of the CLI. But if this can be packed for us to get a 1.7.5 version of the CLI, that would rock for those of us that want to migrate to a newer rev, but can’t yet do so.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
filipesilvacommented, Sep 3, 2018

@arimus we still use source-map-support in https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/angular-cli-files/plugins/karma.ts#L78-L91. We depend on "source-map-support": "^0.5.0" so 0.5.9 should be automatically picked up on reinstalls. If someone is interested in updating the minimum to 0.5.9 I’m happy to review that PR.

Reading through https://github.com/karma-runner/karma/issues/2852 I get the feeling this can happen due to a lot of things. One of them is CORS, and the error message becomes better with the new source-map-support version. But it also seems to happen with a lot of async behaviour.

We should take a look at the examples in https://github.com/karma-runner/karma/issues/2852 and figure out why our error reporting in Angular CLI doesn’t show the right error messages.

1reaction
Sharondiocommented, Sep 10, 2018

Any updates on this? It seems to be getting worse the more tests I add.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - ng test with source map error - Adapter did not report ...
I am setting up the same node and ng environment with old laptop to my new laptop, and then cloning an existing ng...
Read more >
Elevate Digital Suite Third Party Licenses - Unisys
763, karma-ng-html2js-preprocessor · 1.0.0, MIT ... 1247, source-map-support, 0.4.18, MIT. 1248, source-map-support ... 153, guava-jdk5-17.0.jar, Apache 2.0.
Read more >
git projects / Evergreen.git / commitdiff
+npm run test # unit tests. +ng ... + "karma-source-map-support": "^1.2.0", ... + "resolved": "https://registry.npmjs.org/@ng-bootstrap/ng- ...
Read more >
Open source licenses for Code42 platform version 6.0
karma -source-map-support1.2.0. MIT License. karma-sourcemap-loader0.3.7. MIT License. karma-spec-reporter0.0.26. MIT License.
Read more >
Open Source Used In Cisco Tetration Analytics 3.1.1
This document contains licenses and notices for open source software used in ... 1.164 combined-stream 0.0.7 ... 1.509 karma-ng-html2js-preprocessor 0.1.2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found