-
Notifications
You must be signed in to change notification settings - Fork 16
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
Karma hangs with jsdom #27
Comments
This is an interesting one. So, what's happening here is that something in your bundle attempts to perform a synchronous XHR. This request is usually handled by Karma's server. In this case however, Node is blocking in spawnSync and won't respond to the request. In other words, there's a deadlock going on here. There's unfortunately not much for I don't have time to dig further into Angular og Webpack for you, but if you can find a way for it to not perform synchronous XHR, then this will hopefully work. |
Leaving it open for a while, any tips as to how make Webpack cooperate are welcome. |
I couldn't let this one go and did some more digging. It turns out that the synchronous requests are made by source-map-support. There's an issue in angular-cli that prevents me from disabling it, which I've tried to outline below.
I suspect that angular/angular-cli#13062 introduced this behavior. The good news is that --- node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js
+++ node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js
@@ -425,6 +425,9 @@
}
open(method, uri, asynchronous, user, password) {
+ if (typeof asynchronous !== "undefined" && !asynchronous) {
+ throw new Error("Synchronous request prohibited.");
+ }
if (!this._ownerDocument) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
Sidenote: Having a proper way of patching 3rd party libraries is convenient when you can't be bothered to submit a patch yourself, either because you can't wait for it or because your request is too obscure. I've never been on a real project without ever having needed this. One approach I've found to work is having a postinstall script in package.json and a directory containing patches as that shown above.
|
Brilliant! Thanks for the help. Glad you couldn't let it go 😄 . As a suggestion you may want to add this to your README.md given the popularity of the platform. |
@badeball regarding the patching of libs, just wanted to mention that https://github.com/ds300/patch-package helps with that problem as well. Exactly same concept though. It just sorta manages the patches and is cross platform. |
I've tried creating a fresh Angular project and configured Edit: To specify further - it seems like the fix was published with v7.3.1, as shown by |
I will furthermore see if I can warn users of synchronous requests to the Karma server, as it will never really work. |
I was having issues with coverage reports with source maps set to false in an angular repo. Thanks @badeball for your workaround. I also had to increase |
I'm trying to add jsdom to an Angular CLI project and when I switch the browser to jsdom it just hangs indefinitely after building.
Steps to reproduce:
Note: using Angular Cli version 7.1.4
43 "jsdom": "~13.2.0",
44 "karma-jsdom-launcher": "~7.0.0",
At this point the project will compile and then go to a blank screen where it sits until killed with Ctrl+C.
The text was updated successfully, but these errors were encountered: