New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 655694 link

Starred by 3 users

Issue metadata

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



Sign in to add a comment

unhandledrejection sometimes doesn't work

Reported by josh...@gmail.com, Oct 13 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36

Steps to reproduce the problem:
1. Load working/index.html.
2. Notice that it displays two message boxes, one of which is from the unhandledrejection event handler
3. Load notworking/index.html.
4. Notice how it only displays one message box. The unhandledrejection event handler doesn't fire, even though the code is identical.

What is the expected behavior?
unhandledrejection works consistently.

What went wrong?
I'm unable to get unhandledrejection event handlers to fire in my React application. It works in a JSFiddle. After some experimentation, I can reproduce the problem in the attached test cases.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 54.0.2840.59  Channel: stable
OS Version: 10.0
Flash Version: Shockwave Flash 23.0 r0
 
unhandledrejecton.zip
1.5 KB Download

Comment 1 by josh...@gmail.com, Oct 13 2016

It looks like the problem is consistently that unhandledrejection works when it's in the .html file and fails when it's in a separate script file.

A JSFiddle sample (https://jsfiddle.net/6n3pvpx1/), Chrome's Promise Rejection Events Sample (https://googlechrome.github.io/samples/promise-rejection-events/), and my "working" test case all put the event handler within the .html, and all work.  (My React application also works when I put the event handler within the index.html.)

My "notworking" test case and my React application put it in a separate file, and it fails.  I've tried different variations of putting it in a separate file - a DOMContentLoaded handler, a button click handler, a timeout - and all fail.
Cc: ligim...@chromium.org
Labels: pre-stable-54.0.2840.59 Needs-Bisect M-54
Cc: brajkumar@chromium.org
Labels: Needs-Feedback
Tested this issue on Windows-10 using chrome latest stable #54.0.2840.59 by following steps mentioned below.

1. Downloaded file unhandledrejecton.zip
2. Opened index.html file from not working folder
3. Observed a pop up saying "This page says About to fail"
4. Opened index.html file from working folder
5. Observed two pop ups saying "This page says About to fail" and "This page says oh no!"

While testing the same issue on chrome previous version of chrome #35.0.1849.0 & #40.0.2172.0. Observed only one alert saying "About to fail" from both the folders working and not working. Could you please let us is this is the expected behavior of the issue? 

Comment 4 by josh...@gmail.com, Oct 20 2016

Displaying "Oh no!" is the desired behavior. ("unhandledrejection" is commonly used for error handling; the two test cases intentionally trigger a failure then see if they can correctly see it. A real application would have do something more productive than saying, "Oh no!")

According to https://www.chromestatus.com/feature/4805872211460096, unhandledrejection was added in Chrome 49, so I would not expect Chrome 35 or 40 to work.
Labels: -Needs-Feedback -Needs-Bisect
Status: Untriaged (was: Unconfirmed)
As per comment #4 I have rechecked this issue on Windows-10 using chrome M49 #49.0.2623.112 and observed the same behavior as seen on latest stable M54 #54.0.2840.59. 

So considering this to be a non-regression issue and marking it as untriaged.
Components: -Blink>JavaScript Blink>DOM>Events
Event handling is typically not related to V8.

Comment 7 by hayato@chromium.org, Oct 24 2016

Cc: domenic@chromium.org
Owner: yhirano@chromium.org
Status: Assigned (was: Untriaged)
It sounds Promise's issue.

yhirano@, domenic@,
I appreciate if you could triage this issue.

Do you know which bug components we should use for Promise?
Blink>DOM>Events is not appropriate, I think.

Cc: mkwst@chromium.org
Labels: Needs-Feedback
joshkel@, I can see the message when the html and js files are served via http. I cannot see it when they're loaded as file:// resources. Do you agree with it?

window.onerror behaves similarly. Can you check with the following code?

window.onerror = function(e) {
  alert(e);
}

throw 77;

cc-ing mkwst@ as he added ExecutionContext::shouldSanitizeScriptError. If this is the intended behavior, please let me know.

Comment 9 by mkwst@chromium.org, Oct 24 2016

Cc: jochen@chromium.org
If the script is cross-origin to the page, then the page should be getting a sanitized error (e.g. "Script error." as opposed to a detailed error message with a stack trace) via `window.onerror`. It looks like the unhandled rejection flow errors out entirely rather than firing a sanitized event (see step 2 of https://html.spec.whatwg.org/multipage/webappapis.html#the-hostpromiserejectiontracker-implementation).

domenic@, jochen@, was that intentional?
the script error would have zero information, so we figured it's not worthwhile to throw it
https://github.com/domenic/unhandled-rejections-browser-spec/issues/20 has fragments of the discussion :-/

Comment 12 by mkwst@chromium.org, Oct 24 2016

Hrm. It seems like there would be exactly as little information in this as there is in the `window.onerror` event. If we don't consider the one worth sending, why do we send the other? Consistency seems like a reasonable goal here.
in the other case it tells you that the entire script was not executed. For unhandled exceptions, you can only guess what happened

Comment 14 by mkwst@chromium.org, Oct 24 2016

> the entire script

What entire script? It tells you that you had a "Script error." :) But yeah, there's some distinction in behavior between an uncaught exception and an unhandled rejection.
Cc: yhirano@chromium.org
Owner: domenic@chromium.org
Assigning to Domenic to decide whether or not to change the spec here
Status: WontFix (was: Assigned)
I don't think we should change the spec, since as stated it's useless. But if people have some use case for getting some kind of censored version of the event (I guess with both `promise` and `reason` set to null??), please raise that on the HTML spec issue tracker.

Comment 17 by josh...@gmail.com, Oct 28 2016

Thank you for the explanation. I didn't realize that cross-origin policy was what was causing my event handler to fail.

I did some more testing with that knowledge, and I think there may still be a bug. My original scenario was that my unhandledrejection handler wasn't working in a React application, served using webpack-dev-server.  I went back to that today and did some more investigation and found that the event handler fires as long as Chrome Dev Tools are closed.  If Chrome Dev Tools are open, the unhandledrejection handler is ignored.

I've noticed that scripts are listed in Chrome Dev Tools with webpack:// URLs. Does translating the "real" URLs (e.g., http://localhost:8000/assets/app.js) to webpack:// URLs cause them to appear as coming from a different origin, causing unhandledrejection events to appear as cross origin and be ignored?

If you'd like for me to open a new issue for this or put together a full test case using webpack-dev-server, please let me know.

Comment 18 by tkent@chromium.org, Mar 15 2017

Components: -Blink>DOM>Events Blink>DOM
Remove Blink>DOM>Events
Cc: yukishiino@chromium.org swarnasree.mukkala@chromium.org
 Issue 876248  has been merged into this issue.

Sign in to add a comment