Description
Before You File a Documentation Request Please Confirm You Have Done The Following...
- I have looked for existing open or closed documentation requests that match my proposal.
- I have read the FAQ and my problem is not listed.
Suggested Changes
Hi!
[no-floating-promises] cite what follows:
[...]
This rule reports when a Promise is created and not properly handled. Valid ways of handling a Promise-valued statement include:
[...]
- voiding it
[...]
However, voiding a Promise doesn't actually make it handled. The result is just ignored.
If a voided Promise is rejected, an error is still thrown and thus the failure is just ignored. However, the failure is still there. In fact:
- a listener for
unhandledrejection
still gets invoked; - an error is still logged in the console and eventually in enterprise logging systems (e.g. Sentry);
Therefore, it is not exactly correct to say that void
operator is a valid way of handling a Promise. A promise should still be followed by a .catch() (even with a noop function) right after the invokation (not after or in an if).
This code proves what happens. I trusted this package, I voided some Promises I didn't expect could reject and, after enabling Sentry, I ended up with a ton of reports about unhandled rejections.
window.addEventListener("unhandledrejection", (err) => {
console.log("Unhandled Rejection", err);
});
async function f1() {
return Promise.reject("Timeout expired");
}
void f1();
console.log("test");
Logs orders:
- (log)
"test"
- (log)
"Unhandled Rejection"
- (error)
Uncaught (in promise) Timeout expired

I'd improve the documentation by putting a warning on void about this behavior, both above in the list (add a link to ignoreVoid
) and under the ignoreVoid
.
Runtime error messages might get improved as well, but as I'm on an older version of the extension (v6 if I see correctly), I still went to see the documentation to check if the usage is correct.
Code could be improved by requiring the .catch(() => { ... })
even for voided Promises or by setting { ignoreVoid: false }
by default, as the behavior is potentially annoying.
Thank you