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.

Error displays as an empty object

See original GitHub issue

When my query function throws an error, the devtools displays it as an empty object. I would expect it to display the message and maybe stack string properties that the object contains.

If I throw a custom error with additional properties, such as status, it shows up just fine in the devtools. So it seems to only be the default error properties that are not being shown.

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
TkDodocommented, Jul 1, 2022

yeah let’s reopen this and fix it for v4. We initially only used JSON.stringify to display the values, but lots of things (Error included) is not json serializable. That’s why an object works, but an Error instance does not. Now, we have a custom function that serializes BigInt differently already:

https://github.com/TanStack/query/blob/1b918c2e8897e970a471624f7f075026db24e15b/packages/react-query-devtools/src/utils.ts#L117-L126

My idea would be to just use superjson here to cover all cases.

1reaction
TkDodocommented, Aug 25, 2022

Replacing JSON.stringify with SuperJSON.stringify outputs:

I think we can do:

const { json, meta } = superjson.serialize(value)

and then just ignore the meta ?

https://github.com/blitz-js/superjson#advanced-usage

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid empty object error in a loop using Google Apps ...
I'm calling an API and getting data going through its pagination. When I get to the last page, though, the obejct giving me...
Read more >
How to Check if Object is Empty in JavaScript - Samantha Ming
Checking empty object with JavaScript​​ It returns true for objects. And we're covered for null and undefined . It will return false and...
Read more >
LWC controller returns empty objects
I have a problem. Every time, when I'm trying to execute quick action i see this error-message: [e.opportunity is undefined]. Can somebody help ......
Read more >
TypeError: Reduce of empty array with no initial value
This problem appears frequently when combined with a filter ( Array.prototype.filter() , TypedArray.prototype.filter() ) which will remove all elements of the ...
Read more >
Object store v2 store operation does not throw error when Fail ...
This works as designed because when you pass an empty array this is equivalent to passing an empty string and this is not...
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