> I have some code here, and when exactly is this run?
If there are `await` keywords previously in the function, then the line you're looking at will run after these async calls are done. Otherwise it'll run ASAP. Is there something else to it?
If there are `await` keywords previously in the function, then the line you're looking at will run after these async calls are done. Otherwise it'll run ASAP. Is there something else to it?
const example = async () => {
const ifError = Promise.reject("something went wrong")
const value = await someOtherPromise()
await (valueIsOk(value) ? runNextStep(value) : ifError)
}
will always throw.Is the concern you're raising that people may accidentally orphan floating promises? That can be addressed with linter rules. [1][2]
[1]: https://github.com/typescript-eslint/typescript-eslint/blob/...
[2]: https://github.com/typescript-eslint/typescript-eslint/blob/...
Tell that to my junior coworkers. It's probably the single most common cause of async bugs in our codebase.