Closed Bug 1533308 Opened 5 years ago Closed 5 years ago

Error message is missing for uncaught rejected with non-primitive values Promises

Categories

(DevTools :: Console, defect, P2)

65 Branch
defect

Tracking

(firefox69 fixed)

RESOLVED FIXED
Firefox 69
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)

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

Component: Untriaged → General
Product: Firefox → DevTools

Hi Jim, according to you should this bug be moved to the SpiderMonkey bugzilla component or the devtools console component?

Flags: needinfo?(jimb)

To the extent that there is a problem here, I'm pretty sure it's devtools' problem.

Flags: needinfo?(jimb)

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.

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?

Flags: needinfo?(nchevobbe)
Status: UNCONFIRMED → NEW
Component: General → Console
Ever confirmed: true

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.

Blocks: dbg-stacks
Flags: needinfo?(nchevobbe)
Priority: -- → P2
Summary: the behavior of uncaught exception inconsistency in devtools → Error message is missing for uncaught rejected with non-primitive values Promises
Assignee: nobody → bhackett1024
Status: NEW → ASSIGNED
Whiteboard: [debugger-mvp]
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.
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 69
Depends on: 1575306
Regressions: 1581112
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: