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.

generate-thumbnail: `Error serializing return value: TypeError: Converting circular structure to JSON

See original GitHub issue

In this sample: https://github.com/firebase/functions-samples/tree/master/generate-thumbnail

We routinely see the error Error serializing return value: TypeError: Converting circular structure to JSON in the logs during function execution.

We’ve been trying to isolate exactly the point of failure, but testing and debugging with cloud functions is a bit tricky.

Logging it here in case someone at Firebase has an idea.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
inlinedcommented, Jul 25, 2017

That code is a noop from just returning ref.transaction (That it’s a noop is actually part of the acceptance test for a Promise implementation).

The problem you’re running into is that the promised value that ref.transaction returns isn’t serializeable as JSON. The easiest way to fix this (before we fix it in the Firebase SDK) is to transform the value to something like null.

export default functions.database.ref(listenToPath).onWrite(event => {
  if (event.data.changed()) {
      return ref.transaction(previousValue => previousValue + 1).then(() => null);
  }
});

That () => null transforms any success of TransactionResult to a success of typeof null

0reactions
dannycochrancommented, Jul 25, 2017

@inlined thanks for the workaround!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloud Functions for Firebase - Error serializing return value
The function seems to be working properly, however in the logs I keep seeing this Error serializing return value: TypeError: Converting circular ......
Read more >
Converting Circular Structure to JSON - Career Karma
It is an error that can be thrown when attempting to change a value that cannot be changed or when using a value...
Read more >
swift json get request from url Code Example - Grepper
ofType: "json"),. 5. let jsonData = try String(contentsOfFile: bundlePath).data(using: .utf8) {. 6. return jsonData. 7. } 8. } catch {. 9. print(error).
Read more >
TypeError: Converting circular structure to JSON - YouTube
JSON.stringifyType Error : Converting circular structure to JSON -- starting at object with constructor 'Topology' | property 's' - object ...
Read more >
Dealing with "TypeError: Converting circular structure to JSON ...
JavaScript structures that include circular references can't be serialized with a"plain" JSON.stringify . Example:
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