When code contains an explicit await and evaluates to a Promise, it is implicitly awaited
Categories
(DevTools :: Console, defect, P3)
Tracking
(Not tracked)
People
(Reporter: atrigent, Unassigned)
References
(Depends on 1 open bug)
Details
Steps to reproduce:
type, for example:
await 1; fetch("https://httpbin.org/uuid");
fetch(await "https://httpbin.org/uuid");
into dev console
Actual results:
Evaluated result is a Response
Expected results:
Evaluated response should be a Promise
, because this is what fetch
returns. fetch("https://httpbin.org/uuid");
, with the no-op await
s removed, correctly evaluates to a Promise
.
Having looked through the code, I think I can see why this happens, and I could see why you might feel that this isn't worth fixing. However, I feel strongly that the dev console should behave just like the actual language does, to eliminate any potential confusion.
Comment 1•6 months ago
|
||
Yeah, the code we have to handle top level await isn't great, we have Bug 1839588 to make it better
(In reply to Ari Entlich from comment #0)
However, I feel strongly that the dev console should behave just like the actual language does, to eliminate any potential confusion.
Yeah, some people like to have those nice helpers (we have bugs on file to allow re-declaration of let/const, another one to be able to evaluate JSON objects, …)
In your case, you couldn't do top level await, so you'd have to either wrap it in an async iife, or write it Promise-style, using then
, so I guess having the special execution mode does help users.
Something I do want to do for a while is to indicate that we handled an expression differently, and have a way to show what was actually evaluated, so we can avoid some of the confusion
Updated•5 months ago
|
Description
•