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.

XMLStringifier Error

See original GitHub issue

Expected behaviour

To not crash with XMLStringifier Error

Actual behaviour

When running the test, an error is printed to the console like below where only the LOG statements are intended. This is caused from some side effect in THREE.js which I have been able to reproduce outside of my integration tests.

LOG: 'Starting mem test'
WARN: 'THREE.WebGLProgram: gl.getProgramInfoLog()', 'C:\fakepath(474,3-100): warning X3557: loop only executes for 1 iteration(s), forcing loop to unroll

 '
WARN: 'THREE.WebGLProgram: gl.getProgramInfoLog()', 'C:\fakepath(467,3-100): warning X3557: loop only executes for 1 iteration(s), forcing loop to unroll

 '
LOG: '|1482186409| 61.71MB (+39.35MB) | AVG: 39.35MB'
LOG: '|1482186414| 62.35MB (+0.63MB) | AVG: 19.99MB'

As soon as the tests finishes I am presented with this error and then Karma disconnects.

Missing error handler on `socket`.
Error: Invalid character ( ) in string: Chrome 54.0.2840 (Windows 7 0.0.0) LOG: 'Starting mem test'
,Chrome 54.0.2840 (Windows 7 0.0.0) WARN: 'THREE.WebGLProgram: gl.getProgramInfoLog()', 'C:\fakepath(474,3-100): warning X3557: loop only executes for 1 iteration(s), forcing loop to unroll

 '
,Chrome 54.0.2840 (Windows 7 0.0.0) WARN: 'THREE.WebGLProgram: gl.getProgramInfoLog()', 'C:\fakepath(467,3-100): warning X3557: loop only executes for 1 iteration(s), forcing loop to unroll

 '
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186409| 61.71MB (+39.35MB) | AVG: 39.35MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186414| 62.35MB (+0.63MB) | AVG: 19.99MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186420| 102.97MB (+40.62MB) | AVG: 26.87MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186425| 64.62MB (-38.35MB) | AVG: 10.57MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186431| 105.05MB (+40.43MB) | AVG: 16.54MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186436| 66.54MB (-38.52MB) | AVG: 7.36MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186442| 67.45MB (+0.91MB) | AVG: 6.44MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186448| 107.82MB (+40.37MB) | AVG: 10.68MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186454| 69.24MB (-38.58MB) | AVG: 5.21MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: '|1482186460| 109.62MB (+40.38MB) | AVG: 8.73MB'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: 'Removing scene'
,Chrome 54.0.2840 (Windows 7 0.0.0) LOG: 'Final memory after release: 70.227256MB'

 at index 251
  at XMLStringifier.module.exports.XMLStringifier.assertLegalChar (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma-junit-reporter\node_modules\xmlbuilder\lib\XMLStringifier.js:153:15)
  at XMLStringifier.assertLegalChar (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma-junit-reporter\node_modules\xmlbuilder\lib\XMLStringifier.js:4:59)
  at XMLStringifier.module.exports.XMLStringifier.cdata (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma-junit-reporter\node_modules\xmlbuilder\lib\XMLStringifier.js:39:19)
  at new XMLCData (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma-junit-reporter\node_modules\xmlbuilder\lib\XMLCData.js:17:34)
  at XMLElement.module.exports.XMLNode.cdata (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma-junit-reporter\node_modules\xmlbuilder\lib\XMLNode.js:172:15)

  at XMLElement.module.exports.XMLNode.dat (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma-junit-reporter\node_modules\xmlbuilder\lib\XMLNode.js:369:19)
  at [object Object].onBrowserComplete (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma-junit-reporter\index.js:131:29)
  at [object Object].<anonymous> (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\lib\events.js:13:22)
  at emitTwo (events.js:92:20)
  at [object Object].emit (events.js:172:7)
  at [object Object].onComplete (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\lib\browser.js:143:13)
  at Socket.<anonymous> (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\lib\events.js:13:22)
  at emitTwo (events.js:92:20)
  at Socket.emit (events.js:172:7)
  at Socket.onevent (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\lib\socket.js:335:8)
  at Socket.onpacket (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\lib\socket.js:295:12)
  at Client.ondecoded (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\lib\client.js:193:14)
  at Decoder.Emitter.emit (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\socket.io-parser\node_modules\component-emitter\index.js:134:20)
  at Decoder.add (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\socket.io-parser\index.js:247:12)
  at Client.ondata (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\lib\client.js:175:18)
  at emitOne (events.js:77:13)
  at Socket.emit (events.js:169:7)
  at Socket.onPacket (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\lib\socket.js:101:14)
  at emitOne (events.js:77:13)
  at WebSocket.emit (events.js:169:7)
  at WebSocket.Transport.onPacket (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\lib\transport.js:104:8)
  at WebSocket.Transport.onData (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\lib\transport.js:115:8)
  at WebSocket.onData (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\lib\transports\websocket.js:76:30)
  at emitTwo (events.js:87:13)
  at WebSocket.emit (events.js:172:7)
  at Receiver.ontext (C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib\WebSocket.js:816:10)
  at C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib\Receiver.js:477:18
  at C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib\Receiver.js:361:7
  at C:\Users\pfornari\Desktop\Workspace\Code Files\XX XX\XXX-XXXXXXXXXXX\node_modules\karma\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib\PerMessageDeflate.js:247:5
  at afterWrite (_stream_writable.js:354:3)
  at onwrite (_stream_writable.js:345:7)
  at WritableState.onwrite (_stream_writable.js:89:5)
  at afterTransform (_stream_transform.js:79:3)
  at TransformState.afterTransform (_stream_transform.js:54:12)
  at Zlib.callback (zlib.js:615:5)

19 12 2016 17:27:39.685:WARN [Chrome 54.0.2840 (Windows 7 0.0.0)]: Disconnected (1 times)
Chrome 54.0.2840 (Windows 7 0.0.0) ERROR
  Disconnectedundefined
19 12 2016 17:28:09.674:WARN [Chrome 54.0.2840 (Windows 7 0.0.0)]: Disconnected (2 times), because no message in 30000 ms.
Chrome 54.0.2840 (Windows 7 0.0.0) ERROR
  Disconnected, because no message in 30000 ms.

Environment Details

I’m running Windows 7

  • Karma version (output of karma --version): 1.3.0

  • Junit-reporter version 1.1.0, 1.2.0, & 2.0.0

  • Relevant part of your karma.config.js file Simply taking out reporters: ['junit'] will cause the test to pass and not disconnect. Adding it back in will make the error reappear

Steps to reproduce the behaviour

I have been able to recreate this problem outside of my project in a small test setup. I have attached this in a zip folder. Use npm install to get the required dependencies (three, webpack, karma, etc…). Run karma start to run (which will run testOut.js which is a bundle of test.js and THREE.js). You can use webpack to change test.js and rebuild should you want to try other permutations.

karma-test-proj.zip

I found a fix for the moment which is to wrap the console log, warn, and error, functions in another function that substitutes /[^a-zA-Z0-9_]/g with _ but this is just kind of hacky.

EDIT: Workaround

It seems as though this error is caused by this filter in the XML Builder. It seems as though Three.js’s console output must include a control character or some sort. I have changed my sanitizer to only sanitize these characters but I would still rather like an in library solution. Here’s my workaround that fixes this error for me and I get my pretty log output.

["log", "warn", "error"].map((funcName)=>{
    console[funcName + "old"] = console[funcName];
    console[funcName] = function(funcName, ...args) {
        console[funcName + "old"].apply(console, args.map((arg)=>("" + arg)
            .replace(/[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/g,"_")));
    }.bind(console, funcName);
});

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:9

github_iconTop GitHub Comments

2reactions
hicom150commented, Apr 18, 2019

This error should be fixed with #170 💪

1reaction
MarcusRiemercommented, Apr 16, 2019

I am also getting bitten by this issue. My specs sometimes compare Unicode flags in the following manner: expect(t.element.querySelector("button").innerText).toEqual("🇬🇧");. If the spec fails, this crashes the JUnit reporter and it takes the whole test runner with it. We are working around this by simply calling encodeURIComponent on both sides, but that does not quite strike me as an ideal solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to getting response from API, getting XML:stringify Error
Hi Akshay, The error message indicates that the contents of message.body is a JSON object and not an XML DOM or Nodelist. XML.stringify...
Read more >
E4X XML objects throw errors when stringifying them via JSON
Basically when you call JSON.stringify and pass in an E4X XML object (or an object that contains one), it fails because toJSON isn't...
Read more >
xml-stringify - npm
Start using xml-stringify in your project by running `npm i xml-stringify`. There are 3 other projects in the npm registry using xml-stringify.
Read more >
How To Fix String Could Not be Parsed As XML PHP Error
The most likely cause of this error is that the XML data you are trying to process is not valid. Alternatively, the XML...
Read more >
getJSON returns undefined and produces an XML parsing error
I was able to use http://myjson.com/ to store my JSON and get the desired file without the errors showing up. I assume the...
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