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

Issue 634976 link

Starred by 2 users

Issue metadata

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



Sign in to add a comment

Catching a Promise.all returns inconsistent data type

Reported by thd...@gmail.com, Aug 5 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Steps to reproduce the problem:
1. Load vanilla_promises.html and open the console; you should see the "Images loaded" message with the URL array joined into two lines.
2. Now force one of both of the images to be broken by renaming .jpg to .jpgx or something.
3. 

What is the expected behavior?
The catch() should also log an array to be consistent with the array that is returned when the Promise.all succeeds.

What went wrong?
The catch() logs a string. If both images are broken, it only logs the URL returned from the first reject(). This is inconsistent behavior.

Did this work before? N/A 

Chrome version: 51.0.2704.103  Channel: n/a
OS Version: 10.0
Flash Version: Shockwave Flash 22.0 r0
 
vanilla_promises.html
1.4 KB View Download
Cc: msrchandra@chromium.org
Labels: Needs-Feedback
@thodan -- Thank You for the report.
Navigated to the html file provided and observed error messages in the Console.
Is this the actual behavior you are seeing.
Could you please provide any screen cast of the issue which would help us in better understanding and triaging the issue further.
Components: -Blink Blink>JavaScript

Comment 3 by thd...@gmail.com, Aug 9 2016

Sorry, I uploaded the wrong file -- please disregard that file and use this newly attached file instead (vanilla_promises2.html).

The issue in a nutshell: when there is a "success" condition for the Promises.all, the callback returns an array (see the console output). Now try changing both image URLs from .jpg to .aaa or whatever to force an error condition. The expected out is that the error callback also returns an array, but instead it returns a string pass from the first rejected call.
vanilla_promises2.html
1.3 KB View Download
Cc: littledan@chromium.org adamk@chromium.org
Components: -Blink>JavaScript Blink>JavaScript>Language
Is this working as intended?

Comment 5 by thd...@gmail.com, Aug 11 2016

If this is by design, then please change this to an enhancement request. To have a consistent, predictable behavior, both success and error conditions should return either a string or an array (preferred), not one of each.
Cc: domenic@chromium.org
Status: WontFix (was: Unconfirmed)
The semantics of Promise.all make sense to me personally--if any fails, then Promise.all fails, and it doesn't wait for everything else to complete before it completes. It's possible to build basically any Promise combinator you want out of .then(). Promise.all has been shipped in several browsers, so I would have significant reservations from a web-compatibility perspective about changinging it. If you want different Promise functionality shipped by V8, the best thing to do would be to pursue it through the TC39 process. Promise.prototype.finally is in progress this way.

Comment 7 by thd...@gmail.com, Aug 12 2016

@littledan Thanks for the reply; I see your point about potentially breaking existing apps. My use case was loading 10 images concurrently and giving the end user a report of all images that failed to load. I thought if I wanted to short-circuit, then I would use chaining. Since Promise.all also only reports the first error, then in this regards it is no different than chaining.
thdoan, you can see the current specification at https://tc39.github.io/ecma262/#sec-promise.all . The logic is explicitly short-circuiting. Feel free to propose a new library feature to meet your different use case.

Sign in to add a comment