| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3a2e67b commit b6a7052
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,7 +126,7 @@ function handledRejection(promise) { | |||
| 126 | 126 | } | |
| 127 | 127 | ||
| 128 | 128 | const unhandledRejectionErrName = 'UnhandledPromiseRejectionWarning'; | |
| 129 | - function emitWarning(uid, reason) { | ||
| 129 | + function emitUnhandledRejectionWarning(uid, reason) { | ||
| 130 | 130 | const warning = getError( | |
| 131 | 131 | unhandledRejectionErrName, | |
| 132 | 132 | 'Unhandled promise rejection. This error originated either by ' + | |
@@ -144,20 +144,15 @@ function emitWarning(uid, reason) { | |||
| 144 | 144 | } catch {} | |
| 145 | 145 | ||
| 146 | 146 | process.emitWarning(warning); | |
| 147 | - emitDeprecationWarning(); | ||
| 148 | 147 | } | |
| 149 | 148 | ||
| 150 | 149 | let deprecationWarned = false; | |
| 151 | 150 | function emitDeprecationWarning() { | |
| 152 | - if (unhandledRejectionsMode === kDefaultUnhandledRejections && | ||
| 153 | - !deprecationWarned) { | ||
| 154 | - deprecationWarned = true; | ||
| 155 | - process.emitWarning( | ||
| 156 | - 'Unhandled promise rejections are deprecated. In the future, ' + | ||
| 157 | - 'promise rejections that are not handled will terminate the ' + | ||
| 158 | - 'Node.js process with a non-zero exit code.', | ||
| 159 | - 'DeprecationWarning', 'DEP0018'); | ||
| 160 | - } | ||
| 151 | + process.emitWarning( | ||
| 152 | + 'Unhandled promise rejections are deprecated. In the future, ' + | ||
| 153 | + 'promise rejections that are not handled will terminate the ' + | ||
| 154 | + 'Node.js process with a non-zero exit code.', | ||
| 155 | + 'DeprecationWarning', 'DEP0018'); | ||
| 161 | 156 | } | |
| 162 | 157 | ||
| 163 | 158 | // If this method returns true, we've executed user code or triggered | |
@@ -186,7 +181,7 @@ function processPromiseRejections() { | |||
| 186 | 181 | case kThrowUnhandledRejections: { | |
| 187 | 182 | fatalException(reason); | |
| 188 | 183 | const handled = process.emit('unhandledRejection', reason, promise); | |
| 189 | - if (!handled) emitWarning(uid, reason); | ||
| 184 | + if (!handled) emitUnhandledRejectionWarning(uid, reason); | ||
| 190 | 185 | break; | |
| 191 | 186 | } | |
| 192 | 187 | case kIgnoreUnhandledRejections: { | |
@@ -195,12 +190,16 @@ function processPromiseRejections() { | |||
| 195 | 190 | } | |
| 196 | 191 | case kAlwaysWarnUnhandledRejections: { | |
| 197 | 192 | process.emit('unhandledRejection', reason, promise); | |
| 198 | - emitWarning(uid, reason); | ||
| 193 | + emitUnhandledRejectionWarning(uid, reason); | ||
| 199 | 194 | break; | |
| 200 | 195 | } | |
| 201 | 196 | case kDefaultUnhandledRejections: { | |
| 202 | 197 | const handled = process.emit('unhandledRejection', reason, promise); | |
| 203 | - if (!handled) emitWarning(uid, reason); | ||
| 198 | + if (!handled) emitUnhandledRejectionWarning(uid, reason); | ||
| 199 | + if (!deprecationWarned) { | ||
| 200 | + emitDeprecationWarning(); | ||
| 201 | + deprecationWarned = true; | ||
| 202 | + } | ||
| 204 | 203 | break; | |
| 205 | 204 | } | |
| 206 | 205 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,6 @@ | |||
| 21 | 21 | at * | |
| 22 | 22 | at * | |
| 23 | 23 | at * | |
| 24 | - at * | ||
| 25 | 24 | (node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1) | |
| 26 | 25 | at handledRejection (internal/process/promises.js:*) | |
| 27 | 26 | at promiseRejectHandler (internal/process/promises.js:*) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments