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.

Calling `toJSON` unsets unhandled rejection state.

See original GitHub issue

Using v3.5.0 on Chrome v57.0.2987.133

If toJSON is called on a promise instance, the unhandled rejection state is unset.

This means that any promise that gets serialized to JSON will not be caught in an unhandled rejection event.

image

The expected result is that calling toJSON makes no changes to the target instance.

Issue exploration: toJSON calls reason which calls _unsetRejectionIsUnhandled

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
benjamingrcommented, May 14, 2017

@petkaantonov yes, I understand .reason, but people who JSON.stringify an object containing a unhandled rejection promise as a side effect of logging all payloads (for example) would not expect the rejection to be silent - would they?

0reactions
10xjscommented, May 15, 2017

Since the fix proposed by @benjamingr would be a breaking change, I don’t know if it’s the best approach.

One solution could be to add a config option disable JSON serialization altogether, and instead mirror the behavior of the native Promise object.

import Promise from 'bluebird';

Promise.config({
  toJSON: false,
});

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

resolver or addr is not configured for ENS name (argument ...
Hi! I run this code in browser, and can't catch promise rejection. Important: I added await before getContract,however in typings you return Contract, ......
Read more >
React error : Unhandled Rejection (TypeError): this.state ...
The error is telling you that data in your fetch fulfillment handler is not an array. That's what you have to debug. Look...
Read more >
Process | Node.js v19.3.0 Documentation
Rejections can be caught and handled using promise.catch() and are propagated through a Promise chain. The 'unhandledRejection' event is useful for detecting ...
Read more >
WebDriver - W3C on GitHub
The state can be unset by providing an " acceptInsecureCerts ... Upon rejection of promise with reason r , let result be a...
Read more >
2 Server Error Message Reference - MySQL :: Developer Zone
Message: BLOB, TEXT, GEOMETRY or JSON column '%s' can't have a default value ... Message: The prepared statement contains a stored routine call...
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