awaiting for already rejected Promise in console does not throw
Categories
(DevTools :: Console, defect, P3)
Tracking
(Not tracked)
People
(Reporter: user729569, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(3 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0
Steps to reproduce:
let prom = new Promise((resolve, reject) => { reject(new Error("hello")) })
// we get "Uncaught (in promise) Error: hello"
await prom // we get nothing
Actual results:
See code comments above.
Expected results:
Error thrown every time we await.
Both Chrome and Node do this.
Reporter | ||
Comment 1•1 year ago
|
||
Chrome behavior
Reporter | ||
Comment 2•1 year ago
|
||
Node behavior
Reporter | ||
Comment 3•1 year ago
|
||
Firefox behavior
Updated•1 year ago
|
Reporter | ||
Comment 4•1 year ago
|
||
Hello, I don't know how to @ here on this ancient platform, but this bug isn't just limited to the DevTools, it is also present on web pages executing JavaScript.
Comment 5•1 year ago
|
||
(In reply to [:user729569] from comment #4)
Hello, I don't know how to @ here on this ancient platform, but this bug isn't just limited to the DevTools, it is also present on web pages executing JavaScript.
Oh, I did some light testing and wasn't able to reproduce outside of DevTools.
Can you write a script demonstrating the issue (not running in DevTools) ?
Updated•1 year ago
|
Reporter | ||
Comment 6•1 year ago
|
||
<html>
<head>
<script>
(async () =>
{
let prom = new Promise((resolve, reject) => { reject(new Error("hello")) })
// we get "Uncaught (in promise) Error: hello"
await prom // we get nothing
await prom // we get nothing
try
{
await prom // we get nothing
}
catch (e) // never happens. proof that error is not re-thrown.
{
console.log("Error awaiting rejected promise - Good")
console.log(e)
}
})()
</script>
</head>
<body>
hello
</body>
</html>
Reporter | ||
Comment 7•1 year ago
|
||
! Ignore the code snippet above !
<html>
<head>
<script>
(async () =>
{
let prom = new Promise((resolve, reject) => { reject(new Error("hello")) })
// we get "Uncaught (in promise) Error: hello"
try
{
await prom // we get nothing
}
catch (e) // never happens. proof that error is not re-thrown.
{
console.log("Error awaiting rejected promise - Good")
console.log(e)
}
})()
</script>
</head>
<body>
hello
</body>
</html>
Reporter | ||
Comment 8•1 year ago
|
||
Actually, with this ☝️, the catch block does execute, so I think you're right, it is just a DevTools bug 🙂
Comment 9•1 year ago
|
||
This could be improved by having a dedicated mode for the console (tracked at Bug 1839588).
Not a recent regression, P3 S3, but would be nice to fix even before we get the dedicated mode. Contributions would be appreciated.
Comment 10•1 year ago
|
||
probably caused by https://searchfox.org/mozilla-central/rev/c0adc2160976e2c118e2e5709d08aac071fddce9/devtools/server/actors/webconsole.js#900-902
// The promise was rejected. We let the engine handle this as it will report a
// `uncaught exception` error.
response.topLevelAwaitRejected = true;
Description
•