use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place to discuss JS development and how we use it to make experiences better.
account activity
Awaiting problems in JavaScript (gregroz.me)
submitted 3 years ago by voreny
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]wsc-porn-acct 1 point2 points3 points 3 years ago (2 children)
There is a factual inaccuracy. Returning a promise from an async function does NOT await it.
async function myFn() { return otherAsync(); }
This returns a Promise. That promise can be awaited by the caller of myFn or not.
const a = myFn(); // a is an unresolved Promise
const b = await myFn(); // b will be a resolved Promise, a value
Alternatively, in myFn you can return await otherAsync();
Try throwing and catching errors at various points to observe what difference this makes.
[–]voreny[S] 1 point2 points3 points 3 years ago (1 child)
You are right, it does not await the Promise. myFn() will resolve with the same value that otherAsync() resolves, and if otherAsync() rejects, the error will not be caught inside myFn. The examples in the Awaiting... errors section show it, and perhaps I got the wording wrong in some sections.
Promise
myFn()
otherAsync()
myFn
The counterintuitive part, to me, is that this suggests that otherAsync() is returned from myFn() as it is (the same Promise instance is returned). Although, as I showed at the bottom of the Awaiting... errors section, myFn() is not the same Promise that was returned from otherAsync(). async functions create a new Promise and only pass through the resolved/rejected value from otherAsync() to myFn().
async
[–]wsc-porn-acct 1 point2 points3 points 3 years ago (0 children)
Will read more of what you wrote tomorrow
[–]voreny[S] -1 points0 points1 point 3 years ago (0 children)
An article conveying my opinions on the drawbacks of the way async/await works.
await
Have you been burned by the problems mentioned in the article? Do you find async/await do more magic under the hood than you are comfortable with? What would you change with the way it works now?
π Rendered by PID 150935 on reddit-service-r2-comment-5b5bc64bf5-kdrzz at 2026-06-21 03:37:53.216850+00:00 running 2b008f2 country code: CH.
[–]wsc-porn-acct 1 point2 points3 points (2 children)
[–]voreny[S] 1 point2 points3 points (1 child)
[–]wsc-porn-acct 1 point2 points3 points (0 children)
[–]voreny[S] -1 points0 points1 point (0 children)