phantomjs icon indicating copy to clipboard operation
phantomjs copied to clipboard

TypeError: JSON.stringify cannot serialize cyclic structures

Open AnilVartak opened this issue 9 years ago • 2 comments

  1. Which version of PhantomJS are you using? 2.1.1

  2. What steps will reproduce the problem?

  3. Run the attached file from command line (REPL mode) as "phantomjs scan.js http://www.ibm.com" 2.See output error trace that is triggered onError

  4. Which operating system are you using? MacOS Sierra 10.12.2

  5. Did you use binary PhantomJS or did you compile it from source? Binary

  6. Please provide any additional information below. Attaching the sample barebones code. It works for some urls, but as shown above it triggers a TypeError:JSON.stringify error that I cannot bypass.

scan.js.zip

AnilVartak avatar Jan 25 '17 02:01 AnilVartak

I also had this issue. Here's more details about how I got that issue: I'm using PhantomJS with Karma for Jasmine tests (karma-phantomjs-launcher version 1.0.4)

I'm trying to run karma tests using angular cli and PhantomJS (ng test --code-coverage --single-run) but am getting an error which seems to be causing 24 out of my 33 unit tests to fail. When I run the tests with Chrome as the configured browser, all of the tests pass.

PhantomJS 2.1.1 (Windows 7.0.0) AppService should be created FAILED
    TypeError: JSON.stringify cannot serialize cyclic structures. in http://localhost:9876/_karma_webpack_/polyfills.bundle.js (line 5424)
    stringify@[native code]
    stringify@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:5424:28
    displayModal@http://localhost:9876/_karma_webpack_/scripts.bundle.js:4473:57
    createModalContent@http://localhost:9876/_karma_webpack_/scripts.bundle.js:4453:41
    BMS@http://localhost:9876/_karma_webpack_/scripts.bundle.js:7282:43
    BMSService@http://localhost:9876/_karma_webpack_/main.bundle.js:2095:25930
    _createClass@http://localhost:9876/_karma_webpack_/vendor.bundle.js:84475:34
    _createProviderInstance$1@http://localhost:9876/_karma_webpack_/vendor.bundle.js:84447:38
    resolveNgModuleDep@http://localhost:9876/_karma_webpack_/vendor.bundle.js:84432:42
    _createClass@http://localhost:9876/_karma_webpack_
    ...(there was more in the stack but I cropped it)

In other issues people had with Karma and PhantomJS some suggested uncommenting the polyfills.ts file. I figured that might be related since the error seems to be coming from the polyfills bundled file so I tried running the tests with the polyfills commented out and also with them uncommented out and it didn't make a difference either way.

Here is my karma.conf.js file: https://codepen.io/anon/pen/NYBypv

ricazhang avatar Apr 04 '18 01:04 ricazhang

Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

ariya avatar Dec 26 '19 15:12 ariya