Skip to content

Commit 5a3bd50

Browse files
committed
Remove multipleResolves
1 parent 198c8b2 commit 5a3bd50

File tree

27 files changed

+17
-497
lines changed

27 files changed

+17
-497
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ on the console which is very useful. Unfortunately those errors:
2121
[`warning`](https://nodejs.org/api/process.html#process_event_warning) and
2222
[`rejectionHandled`](https://nodejs.org/api/process.html#process_event_rejectionhandled)
2323
making them hard to debug.
24-
- do not include
25-
[`multipleResolves`](https://nodejs.org/api/process.html#process_event_multipleresolves)
26-
errors (when a promise is resolved/rejected twice).
2724
- are inconvenient to [log to an external service](docs/API.md#log).
2825
- are hard to [test](docs/API.md#testing).
2926
- cannot be conditionally skipped.
@@ -101,7 +98,7 @@ Customizes how process errors are logged.\
10198
## level
10299

103100
_Type_: `object`\
104-
_Default_: `{ warning: 'warn', multipleResolves: 'info', default: 'error' }`
101+
_Default_: `{ warning: 'warn', default: 'error' }`
105102

106103
Which log level to use.\
107104
[Full documentation](docs/API.md#level).

docs/API.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ logProcessErrors({
2828
winstonLogger[level](error.stack)
2929
},
3030

31-
level: { multipleResolves: 'debug' },
31+
level: { uncaughtException: 'debug' },
3232

3333
exitOn: ['uncaughtException', 'unhandledRejection'],
3434

@@ -75,16 +75,15 @@ defined or not).
7575
#### level
7676

7777
_Type_: `object`\
78-
_Default_: `{ warning: 'warn', multipleResolves: 'info', default: 'error' }`
78+
_Default_: `{ warning: 'warn', default: 'error' }`
7979

8080
Which log level to use.
8181

8282
Object keys are the error names:
8383
[`uncaughtException`](https://nodejs.org/api/process.html#process_event_uncaughtexception),
8484
[`warning`](https://nodejs.org/api/process.html#process_event_warning),
8585
[`unhandledRejection`](https://nodejs.org/api/process.html#process_event_unhandledrejection),
86-
[`rejectionHandled`](https://nodejs.org/api/process.html#process_event_rejectionhandled),
87-
[`multipleResolves`](https://nodejs.org/api/process.html#process_event_multipleresolves)
86+
[`rejectionHandled`](https://nodejs.org/api/process.html#process_event_rejectionhandled)
8887
or `default`.
8988

9089
Object values are the log level: `'debug'`, `'info'`, `'warn'`, `'error'`,
@@ -96,8 +95,8 @@ import logProcessErrors from 'log-process-errors'
9695

9796
logProcessErrors({
9897
level: {
99-
// Use `debug` log level for `multipleResolves` instead of `info`
100-
multipleResolves: 'debug',
98+
// Use `debug` log level for `uncaughtException` instead of `error`
99+
uncaughtException: 'debug',
101100

102101
// Skip some logs based on a condition
103102
default(error) {
@@ -112,8 +111,7 @@ logProcessErrors({
112111
_Type_: `string[]`\
113112
_Value_: array of [`'uncaughtException'`](https://nodejs.org/api/process.html#process_event_uncaughtexception),
114113
[`'unhandledRejection'`](https://nodejs.org/api/process.html#process_event_unhandledrejection),
115-
[`'rejectionHandled'`](https://nodejs.org/api/process.html#process_event_rejectionhandled),
116-
[`'multipleResolves'`](https://nodejs.org/api/process.html#process_event_multipleresolves)
114+
[`'rejectionHandled'`](https://nodejs.org/api/process.html#process_event_rejectionhandled)
117115
or [`'warning'`](https://nodejs.org/api/process.html#process_event_warning)\
118116
_Default_: `['uncaughtException', 'unhandledRejection']` for Node `>= 15.0.0`,
119117
`['uncaughtException']` otherwise.
@@ -209,8 +207,7 @@ available as a third argument to [`log`](#log).
209207
_Type_: `string`\
210208
_Value_: [`'UncaughtException'`](https://nodejs.org/api/process.html#process_event_uncaughtexception),
211209
[`'UnhandledRejection'`](https://nodejs.org/api/process.html#process_event_unhandledrejection),
212-
[`'RejectionHandled'`](https://nodejs.org/api/process.html#process_event_rejectionhandled),
213-
[`'MultipleResolves'`](https://nodejs.org/api/process.html#process_event_multipleresolves)
210+
[`'RejectionHandled'`](https://nodejs.org/api/process.html#process_event_rejectionhandled)
214211
or [`'Warning'`](https://nodejs.org/api/process.html#process_event_warning)
215212

216213
#### error.stack

examples/after.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77

88
import logProcessErrors from 'log-process-errors'
99

10-
import {
11-
uncaughtException,
12-
unhandledRejection,
13-
warning,
14-
multipleResolves,
15-
} from './errors.js'
10+
import { uncaughtException, unhandledRejection, warning } from './errors.js'
1611

1712
// Initialization
1813
logProcessErrors()
@@ -21,4 +16,3 @@ logProcessErrors()
2116
uncaughtException()
2217
unhandledRejection()
2318
warning()
24-
multipleResolves()

examples/before.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@
66
// An online demo is also available at:
77
// https://repl.it/@ehmicky/log-process-errors
88

9-
import {
10-
uncaughtException,
11-
unhandledRejection,
12-
warning,
13-
multipleResolves,
14-
} from './errors.js'
9+
import { uncaughtException, unhandledRejection, warning } from './errors.js'
1510

1611
// Emit different types of process errors.
1712
uncaughtException()
1813
unhandledRejection()
1914
warning()
20-
multipleResolves()

examples/errors.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,3 @@ export const warning = function () {
2626
detail: 'opts.force is deprecated',
2727
})
2828
}
29-
30-
// Emit a `multipleResolves` event
31-
export const multipleResolves = function () {
32-
// eslint-disable-next-line promise/avoid-new
33-
return new Promise((resolve, reject) => {
34-
resolve({ success: true })
35-
reject(new Error('Cannot send request'))
36-
})
37-
}

examples/level.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
import logProcessErrors from 'log-process-errors'
99

10-
import { multipleResolves, warning } from './errors.js'
10+
import { warning, uncaughtException } from './errors.js'
1111

1212
// Initialization
1313
// Changes which log level to use
1414
logProcessErrors({
1515
level: {
16-
// Use `debug` log level for `multipleResolves` instead of `info`
17-
multipleResolves: 'debug',
16+
// Use `debug` log level for `uncaughtException` instead of `error`
17+
uncaughtException: 'debug',
1818

1919
// Skip some logs based on a condition
2020
default(error) {
@@ -31,5 +31,5 @@ const shouldSkip = function ({ message }) {
3131
// This deprecation `warning` will be silent
3232
warning()
3333

34-
// This `multipleResolves` process error will use a `debug` log level
35-
multipleResolves()
34+
// This `uncaughtException` process error will use a `debug` log level
35+
uncaughtException()

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"uncaughtException",
2929
"unhandledRejection",
3030
"rejectionHandled",
31-
"multipleResolves",
3231
"debugging",
3332
"testing",
3433
"test"

src/error/message.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,11 @@ const rejectionHandled = function ({ value }) {
3333
return `a promise was rejected and handled too late: ${serialize(value)}`
3434
}
3535

36-
// The default level is `event` because it does not always indicate an error:
37-
// https://github.com/nodejs/node/issues/24321
38-
const multipleResolves = function ({
39-
rejected,
40-
value,
41-
nextRejected,
42-
nextValue,
43-
}) {
44-
const rejectedStr = REJECTED_NAME[rejected]
45-
const nextRejectedStr = REJECTED_NAME[nextRejected]
46-
const again = rejected === nextRejected ? ' again' : ''
47-
const state = again ? rejectedStr : 'resolved/rejected'
48-
49-
return `a promise was ${state} multiple times:
50-
Initially ${rejectedStr} with: ${serialize(value)}
51-
Then ${nextRejectedStr}${again} with: ${serialize(nextValue)}`
52-
}
53-
54-
const REJECTED_NAME = {
55-
true: 'rejected',
56-
false: 'resolved',
57-
}
58-
5936
const MESSAGES = {
6037
uncaughtException,
6138
warning,
6239
unhandledRejection,
6340
rejectionHandled,
64-
multipleResolves,
6541
}
6642

6743
// We use `util.inspect()` instead of `JSON.stringify()` or a third-party

src/exit.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const EVENTS_ARR = [
5656
'uncaughtException',
5757
'unhandledRejection',
5858
'rejectionHandled',
59-
'multipleResolves',
6059
'warning',
6160
]
6261
const EVENTS = new Set(EVENTS_ARR)

src/handle/event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const NO_PROMISE_EVENTS = new Set([
4747
'unhandledRejection',
4848
])
4949

50-
// `rejectionHandled` and `multipleResolves` otherwise use `await promise`
50+
// `rejectionHandled` otherwise use `await promise`
5151
const getPromiseValue = async function ({ promise }) {
5252
try {
5353
return { rejected: false, value: await promise }

0 commit comments

Comments
 (0)