New issue
Advanced search Search tips

Issue 779232 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner:
Closed: Oct 3
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Devtools complain of synchronously rejected promises created by `new Promise(...)` in loaded scripts

Reported by impinb...@gmail.com, Oct 27 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36

Steps to reproduce the problem:
1. Create an HTML file with the following contents:

```html
<!DOCTYPE html>
<script>
new Promise((_, reject) => reject(new Error("foo")))
.catch(() => {})
</script>
```

Alternatively, you can use this a similar effect:

```html
<!DOCTYPE html>
<script>
Promise.reject(new Error("foo"))
.catch(() => {})
</script>
```

2. Load it in Chrome with the devtools open (refresh optional)

What is the expected behavior?
Nothing to happen - the potentially unhandled synchronous rejection should be ignored and reported to the console when actually collected without proper recovery.

What went wrong?
It stops the world and brings up the step debugger.

Did this work before? No 

Chrome version: 62.0.3202.62  Channel: beta
OS Version: OS X 10.12.6
Flash Version: Shockwave Flash 27.0 r0

I'm using a coroutine utility that returns a promise, but works synchronously to work reliably with IndexedDB queries (since most other browsers don't persist connections across microtasks). For similar reasons, it returns a synchronously rejected promise on synchronous errors.

Oh, and you *could* do some limited static analysis to see if it's eventually chained - if you know it's immediately awaited, `then` is immediately called from its call site, or it's returned from a `then` callback, then you could propagate that via added context in the call graph to still know if a synchronous rejection is really guaranteed to be unhandled.
 
Owner: kozy@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 2 by kozy@chromium.org, Dec 4 2017

Cc: kozy@chromium.org pnangunoori@chromium.org
 Issue 735205  has been merged into this issue.
Status: WontFix (was: Assigned)
I would suggest to use "Never pause here" feature [1] here.

Static analysis would not help us in this case. When reject is called in first example, we do not now what function will be called on promise. Yes, we can parse code and detect that something named "catch" will be called, but it might be not original promise catch, since you can redefine catch function on promise easily.

[1] https://medium.com/@theroccob/never-pause-here-undoing-breakpoints-in-chrome-devtools-97e64cd06086

Sign in to add a comment