WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
241088
Promise.race(123); does not throw an error
https://bugs.webkit.org/show_bug.cgi?id=241088
Summary
Promise.race(123); does not throw an error
845043157
Reported
2022-05-29 20:34:32 PDT
Run the program: Promise.race(123).then(function(value){ console.log(value); }); Actual results: (print nothing) Expected results: In V8,it throws an typeerror:"TypeError:number 123 is not iterable (cannot read property Symbol(Symbol.iterator))". In ES6,it writes that Promise.race() needs an iterable parameter. So,I think that it may be a bug.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2022-06-05 20:35:15 PDT
<
rdar://problem/94415890
>
Yusuke Suzuki
Comment 2
2022-06-07 03:35:59 PDT
It is V8's bug.
https://tc39.es/ecma262/#sec-promise.race
step-6 should reject the returned promise, not throwing an error.
845043157
Comment 3
2022-06-07 06:32:29 PDT
When I run the follow program: 1.js: Promise.race(123); print(1); V8: 1 1.js:1: TypeError: number 123 is not iterable (cannot read property Symbol(Symbol.iterator)) Promise.race(123); ^ TypeError: number 123 is not iterable (cannot read property Symbol(Symbol.iterator)) at Function.race (<anonymous>) at 1.js:1:9 spidermonkey: 1 Unhandled rejection: (new TypeError("Argument of Promise.race is not iterable", "1.js", 1)) Stack: @1.js:1:9 jsc: 1 'Promise.race(123);' is wrong code but the output of jsc looks like it is ok.I think it may be better to throw an error or warning tell users the code is wrong.
Yusuke Suzuki
Comment 4
2022-06-07 06:46:52 PDT
(In reply to 845043157 from
comment #3
)
> When I run the follow program: > 1.js: > Promise.race(123); > print(1); > > V8: > 1 > 1.js:1: TypeError: number 123 is not iterable (cannot read property > Symbol(Symbol.iterator)) > Promise.race(123); > ^ > TypeError: number 123 is not iterable (cannot read property > Symbol(Symbol.iterator)) > at Function.race (<anonymous>) > at 1.js:1:9
This V8's behavior is not aligned to the spec (spec requires rejecting the resulted promise, not throwing an error).
> > spidermonkey: > 1 > Unhandled rejection: (new TypeError("Argument of Promise.race is not > iterable", "1.js", 1)) > Stack: > @1.js:1:9
SpiderMonkey shell dumps Unhandled rejection too. In JSC, you can get it via, setUnhandledRejectionCallback(function (error) { // When unhandled rejection happens, this callback is called. });
> > jsc: > 1 > > 'Promise.race(123);' is wrong code but the output of jsc looks like it is > ok.
You can catch the rejected promise via, Promise.race(123).catch(function (error) { // Here, you will get an error in JSC / SpiderMonkey. }); I think it may be better to throw an error or warning tell users the code
> is wrong.
Yusuke Suzuki
Comment 5
2022-06-07 06:54:11 PDT
Putting a default unhandled rejection handler, which dumps log, sounds interesting idea, though it is not compatible with the existing JSC stress tests. So probably, we should add a command line flag to switch that if we add that :)
845043157
Comment 6
2022-06-07 18:08:18 PDT
Thank you for your further explication.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug