Error message is missing for uncaught rejected with non-primitive values Promises
Categories
(DevTools :: Console, defect, P2)
Tracking
(firefox69 fixed)
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: litbear, Assigned: bhackett1024)
References
(Blocks 1 open bug, Regressed 1 open bug)
Details
(Whiteboard: [debugger-mvp])
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0
Steps to reproduce:
open devtools and typed statements as follow:
new Promise((resolve, reject) => {setTimeout(reject, 0, 'foo')}) // reject string
new Promise((resolve, reject) => {setTimeout(reject, 0, new Error('bar'))}) // reject an error object
new Promise((resolve, reject) => {setTimeout(reject, 0)}) // rejectd undefined
new Promise((resolve, reject) => {setTimeout(reject, 0, foo)}) // undefined variable
new Promise((resolve, reject) => {setTimeout(reject, 0, Object)}) // build variable
Actual results:
// firefox 65.0.2 win x64
new Promise((resolve, reject) => {setTimeout(reject, 0, 'foo')})
// uncaught exception: foo
new Promise((resolve, reject) => {setTimeout(reject, 0, new Error('bar'))})
// Error: bar
new Promise((resolve, reject) => {setTimeout(reject, 0)})
// uncaught exception: undefined
new Promise((resolve, reject) => {setTimeout(reject, 0, foo)})
// ReferenceError: foo is not defined
new Promise((resolve, reject) => {setTimeout(reject, 0, Object)})
// no error output
Expected results:
the behavior of uncaught exception inside Promise constructor should be consistent
Updated•6 years ago
|
Comment 1•6 years ago
|
||
Hi Jim, according to you should this bug be moved to the SpiderMonkey bugzilla component or the devtools console component?
Comment 2•6 years ago
|
||
To the extent that there is a problem here, I'm pretty sure it's devtools' problem.
Comment 3•6 years ago
|
||
Most of these cases are fine, but let me start with the one that does seem like
a bug:
new Promise((resolve, reject) => {setTimeout(reject, 0, Object)})
// no error output
This is a mystery to me. I do not understand why rejecting a function would
affect the behavior of the reject
function. This may be a corner of the
Promise
specification that I'm not familiar with, but it could also be a
Firefox bug.
Taking the others one by one:
new Promise((resolve, reject) => {setTimeout(reject, 0, 'foo')})
// uncaught exception: foo
This seems fine. It's the same behavior one would get if one evaluated the below:
setTimeout((v) => { throw v; }, 0, 'foo')
So I think that's consistent.
new Promise((resolve, reject) => {setTimeout(reject, 0, new Error('bar'))})
// Error: bar
Throwing an error produces a more detailed error message, using the error's
toString
method. Seems good.
new Promise((resolve, reject) => {setTimeout(reject, 0)})
// uncaught exception: undefined
This is the same as throwing 'foo'
, except that it calls reject
with
no arguments, so the rejected value is undefined
instead of a string. This
seems consistent.
new Promise((resolve, reject) => {setTimeout(reject, 0, foo)})
// ReferenceError: foo is not defined
This error is occurring during the Promise
constructor's call to the arrow
function. The promise is never rejected. The behavior is exactly the same as that
from:
new Promise(() => { foo; });
Firefox's behavior seems correct here.
Comment 4•6 years ago
|
||
Nicolas, the first case I describe above looks like it could be a bug in the way the console reports rejected promises. Would you be willing to take a look?
Updated•6 years ago
|
Comment 5•6 years ago
|
||
Looks like something is wrong when rejecting objects, since the following:
new Promise((resolve, reject) => {setTimeout(reject, 0, "oops")})
produces:
uncaught exception: oops
This actually hits the nsIConsoleService observer (devtools/server/actors/webconsole/listeners/console-service.js#57-66), while rejecting any non-primitive value does not.
I'm not sure how to proceed from there since things happen in C++ kingdom before that.
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 6•6 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Pushed by bhackett@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/496c1e094336 Report rejected non-exception objects to the console, r=kmag,arai.
Comment 8•5 years ago
|
||
bugherder |
Description
•