Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the DEP0018 deprecation #32081

Closed
mike-marcacci opened this issue Mar 4, 2020 · 3 comments
Closed

Remove the DEP0018 deprecation #32081

mike-marcacci opened this issue Mar 4, 2020 · 3 comments
Labels
promises Issues and PRs related to ECMAScript promises.

Comments

@mike-marcacci
Copy link

Is your feature request related to a problem? Please describe.
Deprecation DEP0018, which is associated with the poorly named UnhandledPromiseRejectionWarning, is misleading and fundamentally incorrect. Asynchronously handling promises cannot be deprecated, as it is a basic tenant of the promise spec.

When a promise that is handled asynchronously is rejected before the handler is attached, the following is currently logged:

(node:45) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:45) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Describe the solution you'd like
While preserving the warning may be useful, the deprecation (which will never happen) should be removed.

When a promise that is handled asynchronously is rejected before the handler is attached, only the following should be logged:

(node:45) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Describe alternatives you've considered
Finalizing this proposed deprecation is tracked by #20392. This proposal is deeply flawed and would have far-reaching consequences if implemented. In #31148 I proposed a strategy to address the same pain points in a correct, more generic way. Regardless of whether my approach is taken or not, async handling of promises is a core feature that simply cannot be deprecated, and we should remove the erroneous deprecation accordingly.

@mehmetkoc182
Copy link

Looks like there is some push back on this mostly due to performance concerns. Would it make everyone happy if you implemented this behind a flag?

@jasnell
Copy link
Member

jasnell commented Mar 11, 2020

At this point, the overwhelming and stable consensus within Node.js core has been to maintain the deprecation. However, it is possible to use the --unhandled-rejections=none command-line argument (and within the NODE_OPTIONS environment variable to achieve the behavior you're looking for..

$ node --unhandled-rejections=none

$ NODE_OPTIONS=--unhandled-rejections=none node

@devsnek devsnek added the promises Issues and PRs related to ECMAScript promises. label Mar 11, 2020
@jasnell
Copy link
Member

jasnell commented Jun 19, 2020

Closing as there is no further action to take on this specific issue. The strategy around unhandled rejections is being refined in other PRs and issues

@jasnell jasnell closed this as completed Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
promises Issues and PRs related to ECMAScript promises.
Projects
None yet
Development

No branches or pull requests

4 participants