Pnpjs: JSON.stringify Converting circular structure to JSON Data when LogLevel.Verbose and using batching with getPaged()

Created on 11 Dec 2018  路  3Comments  路  Source: pnp/pnpjs

Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your
needs please complete the below template to ensure we have the details to help. Thanks!

Please check out the Docs to see if your question is already addressed there. This will help us ensure our documentation covers the most frequent questions.

Category

  • [ ] Enhancement
  • [x ] Bug
  • [ ] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: [ 1.2.7 ]

Please specify what version(s) of SharePoint you are targeting: [ SPO ]

If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.

Expected / Desired Behavior / Question

When Logger is configured with LogLevel.Verbose and using batching functionality + paging (e.g. getPaged) expectation is to get back paged items after calling batch.execute().

Observed Behavior

Receive Error: Message: Converting circular structure to JSON Data: {} that is thrown from line 55 in listeners.ts where JSON.stringify(entry.data) is executed.

Changing any one of 3 variables resolves the issue which are my work around for now.

  1. Change .getPaged() to just .get()
  2. Don't batch the requests
  3. Change LogLevel to something higher than Verbose like Info (my approach for now)

Steps to Reproduce

Set up logger and use ConsoleListener
`

        Logger.subscribe(new ConsoleListener());
        Logger.activeLogLevel = LogLevel.Verbose;

Make a batched, paged request for list items

        let batch = sp.web.createBatch();
        sp.web.lists.getByTitle("SomeList").items
            .inBatch(batch)
            .getPaged()
            .then(r => {
                pagedItems.mainPagedItemCollection = r;
                debugger;
            });

        await batch.execute()
            .catch(e => {
                debugger;
            });

`

code investigate bug

All 3 comments

Wow, not a common set of circumstances, nice find. Will have a look, thanks.

Agree. I always seem to be the guy in the one off scenarios. Thanks for taking a look and putting a try/catch around that so it will at least continue on successfully.

Yep - logging should never crash an application and we broke that rule. Thanks again for letting us know :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ITAndy23 picture ITAndy23  路  3Comments

AJIXuMuK picture AJIXuMuK  路  3Comments

SpliceVW picture SpliceVW  路  3Comments

DennisGaida picture DennisGaida  路  3Comments

KieranDaviesV picture KieranDaviesV  路  3Comments