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

v13.6.0 proposal #31238

Merged
merged 180 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
f8aa365
assert: use for...of
soar-beep Dec 16, 2019
32805a9
deps,src,test: update to uvwasi 0.0.3
cjihrig Dec 15, 2019
d6f9420
doc,lib,src,test: rename WASI CLI flag
cjihrig Dec 15, 2019
d36ae62
test: remove obsolete WASI test
cjihrig Dec 15, 2019
0e864a3
benchmark: update manywrites back pressure
ronag Dec 15, 2019
7815d5f
doc: update message.url example in http.IncomingMessage
saitolume Dec 7, 2019
3753f47
test: use tmpdir.refresh() in test-esm-windows.js
richardlau Dec 16, 2019
7f6a0ed
fs: allow overriding fs for streams
ronag Aug 11, 2019
cc8c0b4
doc: reference worker threads on signal events
legendecas Dec 16, 2019
a386114
doc: clarify required flag for extensionless esm
azz Nov 26, 2019
e5a4155
src: fix compiler warning in env.cc
addaleax Dec 18, 2019
6b65caf
src: list used functions on headers
juanarbol Dec 6, 2019
f570de8
events: allow monitoring error events
Flarna Dec 12, 2019
4df3652
buffer: improve .from() error details
BridgeAR Sep 23, 2019
33c5dbe
errors: improve ERR_INVALID_ARG_TYPE
BridgeAR Sep 23, 2019
54c471a
test: fix flaky test-http2-client-upload
Flarna Oct 8, 2019
625744d
benchmark: add clear connections to secure-pair
DiegoTUI May 30, 2019
93cf123
test: fix long lines
cjihrig Dec 18, 2019
37ffa8c
bootstrap: use different scripts to setup different configurations
joyeecheung Dec 9, 2019
21ef3d6
dgram: use for...of
trivikr Dec 14, 2019
dadccb7
test: fix common.enoughTestMem
Trott Dec 20, 2019
3c9e435
test: unflake async hooks statwatcher test
lundibundi Nov 10, 2019
e5980a1
test: cover vm with negative tests
Dec 18, 2019
a83d338
lib: improve spelling and grammar in comment
datatypevoid Dec 19, 2019
49a7e73
src: make --use-largepages a runtime option
Dec 13, 2019
c779421
tools: update ESLint to 6.8.0
cjihrig Dec 20, 2019
07e82db
test: get lib/wasi.js coverage to 100%
cjihrig Dec 20, 2019
afecc97
events: add EventEmitter.on to async iterate over events
mcollina May 30, 2019
7e13ae7
deps: V8: cherry-pick d3a1a5b6c491
targos Dec 17, 2019
614b2c5
lib: further simplify assertions in vm/module
addaleax Dec 6, 2019
a27edd8
src,test: use v8::Global instead of v8::Persistent
addaleax Dec 18, 2019
a7988ab
doc: avoid using v8::Persistent in addon docs
addaleax Dec 18, 2019
28a62c3
tools,src: forbid usage of v8::Persistent
addaleax Dec 18, 2019
796a9c0
doc,vm,test: remove _sandbox_ from vm documentation
Trott Dec 22, 2019
69d6e97
doc: implement minor improvements to BUILDING.md text
Trott Dec 23, 2019
86f2e86
http2: wait for session to finish writing before destroy
lundibundi Dec 7, 2019
ba0682e
http2: wait for session socket writable end on close/destroy
lundibundi Dec 8, 2019
7611d5b
util: add colors to debuglog()
BridgeAR Dec 12, 2019
925dd8e
repl: fix preview of lines that exceed the terminal columns
BridgeAR Dec 17, 2019
09ca8be
repl: implement reverse search
BridgeAR Dec 16, 2019
92dcf3e
readline: small refactoring
BridgeAR Dec 17, 2019
ffbf790
readline: set null as callback return in case there's no error
BridgeAR Dec 18, 2019
a699808
util: add (typed) array length to the default output
BridgeAR Dec 19, 2019
048b7f4
tools: fix Raspbian armv7 build
AHgPuK Dec 20, 2019
ca53f02
benchmark: use let instead of var in child_process
dnlup Dec 20, 2019
44d03e8
dgram: test to add and to drop specific membership
universePrisoner Dec 20, 2019
9141366
doc: improve doc net:server.listen
dev-script Dec 23, 2019
1463214
stream: simplify isBuf
ronag Dec 23, 2019
bca23b9
stream: reset flowing state if no 'readable' or 'data' listeners
ronag Dec 20, 2019
7b2bf20
tls: add PSK support
lundibundi Oct 29, 2018
83330a0
timers: do less work in insert
apapirovski Apr 22, 2019
fe4f55e
timers: fix refresh for expired timers
apapirovski Apr 22, 2019
4caf457
doc: add unrepresented flags docs for configure
rexagod Jun 5, 2019
ca22ce2
stream: pipeline should use req.abort() to destroy response
ronag Dec 21, 2019
1357c97
doc: standardize usage of hostname vs. host name
Trott Dec 23, 2019
80732cd
src: port --bash-completion to C++
joyeecheung Feb 3, 2019
4292f64
doc: fix anchors and subtitle in BUILDING.md
sutangu Nov 6, 2019
60dd183
src: prevent hard coding stack trace limit
legendecas Dec 1, 2019
e28e873
test: skip the unsupported test cases for IBM i
dmabupt Dec 6, 2019
7fe8399
deps: V8: cherry-pick d406bfd64653
sam-github Dec 9, 2019
647f3c7
deps: V8: cherry-pick 687d865fe251
ChALkeR Dec 17, 2019
01fd3be
benchmark: include writev in benchmark
ronag Dec 23, 2019
0999d53
repl: use public getCursorPos()
cjihrig Dec 25, 2019
baf8730
build: re-introduce --use-largepages as no-op
Dec 24, 2019
a5937c7
deps: uvwasi: cherry-pick 64e59d5
cjihrig Dec 24, 2019
2ec817e
deps: uvwasi: cherry-pick 75b389c
cjihrig Dec 24, 2019
87f15c0
wasi: throw on failed uvwasi_init()
cjihrig Dec 22, 2019
efc97fd
doc: add --enable-source-maps man page entry
cjihrig Dec 24, 2019
23013e3
doc: add --force-context-aware man page entry
cjihrig Dec 24, 2019
1033760
doc: add --inspect-publish-uid man page entry
cjihrig Dec 24, 2019
d131877
build: fixes build for some os versions
devnexen Oct 27, 2019
31bbae7
zlib: allow writes after readable 'end' to finish
addaleax Dec 24, 2019
54caadc
src: enable stack trace printing for V8 check failures
addaleax Dec 24, 2019
ca05a5b
build: switch realpath to pwd
bcoe Dec 26, 2019
ce60a80
doc: allow <code> in header elements
Trott Dec 23, 2019
9979f82
doc,dns: use code markup/markdown in headers
Trott Dec 23, 2019
ff82890
doc: use code markup/markdown in headers in addons documentation
Trott Dec 23, 2019
118df63
doc,assert: use code markup/markdown in headers
Trott Dec 23, 2019
32e5895
doc,async_hooks: use code markup/markdown in headers
Trott Dec 23, 2019
0e0d45b
doc,buffer: use code markup/markdown in headers
Trott Dec 23, 2019
405bf8c
doc,child_process: use code markup/markdown in headers
Trott Dec 23, 2019
27790fc
doc,cluster: use code markup/markdown in headers
Trott Dec 24, 2019
f8a6eda
doc,console: use code markup/markdown in headers
Trott Dec 24, 2019
df5ec4e
doc,crypto: use code markup/markdown in headers
Trott Dec 24, 2019
7afe69c
doc: use code markup/markdown in headers in deprecations documentation
Trott Dec 24, 2019
4a42230
doc,dgram: use code markup/markdown in headers
Trott Dec 24, 2019
decfcaf
doc,domain: use code markup/markdown in headers
Trott Dec 24, 2019
665a662
doc,errors: use code markup/markdown in headers
Trott Dec 24, 2019
fbb217a
doc,esm: use code markup/markdown in headers
Trott Dec 24, 2019
db01d0f
doc,events: use code markup/markdown in headers
Trott Dec 24, 2019
e7f7e45
doc,fs: use code markup/markdown in headers
Trott Dec 24, 2019
dcce8b6
doc: use code markup/markdown in headers in globals documentation
Trott Dec 24, 2019
cdb79fc
doc,http: use code markup/markdown in headers
Trott Dec 24, 2019
3062bcb
doc,http2: use code markup/markdown in headers
Trott Dec 24, 2019
3571df3
doc,https: use code markup/markdown in headers
Trott Dec 24, 2019
699b31f
doc,inspector: use code markup/markdown in headers
Trott Dec 24, 2019
7d25e44
doc,module: use code markup/markdown in headers
Trott Dec 24, 2019
927b37f
doc,net: use code markup/markdown in headers
Trott Dec 24, 2019
9de9146
doc,os: use code markup/markdown in headers
Trott Dec 24, 2019
5921654
doc,path: use code markup/markdown in headers
Trott Dec 24, 2019
3ee3e6f
doc,perf_hooks: use code markup/markdown in headers
Trott Dec 24, 2019
8c12652
doc,process: use code markup/markdown in headers
Trott Dec 24, 2019
f0bc628
doc,punycode: use code markup/markdown in headers
Trott Dec 24, 2019
125a59a
doc,querystring: use code markup/markdown in headers
Trott Dec 24, 2019
128a69d
doc,readline: use code markup/markdown in headers
Trott Dec 24, 2019
38e09f8
doc,repl: use code markup/markdown in headers
Trott Dec 24, 2019
4c5a985
doc,stream: use code markup/markdown in headers
Trott Dec 24, 2019
cf563bb
doc,string_decoder: use code markup/markdown in headers
Trott Dec 24, 2019
450d9a2
doc,timers: use code markup/markdown in headers
Trott Dec 24, 2019
d6d507a
doc,tls: use code markup/markdown in headers
Trott Dec 24, 2019
9d2082b
doc,tty: use code markup/markdown in headers
Trott Dec 24, 2019
73c598a
doc,url: use code markup/markdown in headers
Trott Dec 24, 2019
a6f16b3
doc,zlib: use code markup/markdown in headers
Trott Dec 24, 2019
4672e10
doc,util: use code markup/markdown in headers
Trott Dec 24, 2019
342d337
doc,v8: use code markup/markdown in headers
Trott Dec 24, 2019
cb3c3fc
doc,worker: use code markup/markdown in headers
Trott Dec 24, 2019
e6fbde5
doc,vm: use code markup/markdown in headers
Trott Dec 25, 2019
1bcc07b
doc,wasi: use code markup/markdown in headers
Trott Dec 25, 2019
4c29a6e
doc: update parameter type for fs.chmod()
santoshyadavdev Dec 27, 2019
72d70d5
doc: improve dns introduction
Trott Dec 25, 2019
2c6f817
src: make large_pages node.cc include conditional
lundibundi Dec 24, 2019
990760e
test: log errors in test-http2-propagate-session-destroy-code
lundibundi Dec 23, 2019
b8ccf30
benchmark: replace var with let/const in cluster benchmark
dnlup Dec 20, 2019
16f60ce
test: increase coverage for _http_incoming.js
Trott Dec 25, 2019
97ce0a3
lib: replace var with let/const
kresimirfranin Nov 12, 2019
d2ab877
build: warn upon --use-largepages config option
Dec 26, 2019
6855788
doc: update parameter type for fsPromises.chmod()
cjihrig Dec 27, 2019
53c6a1e
doc: update mode type for fchmod() functions
cjihrig Dec 27, 2019
2313b9e
doc: update mode type for fs open() functions
cjihrig Dec 27, 2019
a37a88f
doc: update mode type for process.umask()
cjihrig Dec 27, 2019
1fa8e49
doc: update mode type for mkdir() functions
cjihrig Dec 27, 2019
4f32bbb
fs: use consistent defaults in sync stat functions
cjihrig Dec 26, 2019
bd047e8
module: self resolve bug fix and esm ordering
guybedford Dec 17, 2019
18b34de
doc: fix createDiffieHellman generator type
tniessen Dec 28, 2019
799b509
meta: clarify scope of new nodejs.org issue choice
DerekNonGeneric Dec 28, 2019
8491e1c
wasi: fix serdes bugs from snapshot1 migration
cjihrig Dec 28, 2019
10f7169
zlib: use for...of
trivikr Dec 21, 2019
efa0bd8
test: refactor common.expectsError
BridgeAR Dec 25, 2019
85d152f
tools: allow the travis commit message job to fail
BridgeAR Dec 27, 2019
24a0212
esm: empty ext from pkg type/main doesnt affect format
bfarias-godaddy Dec 18, 2019
b657a64
doc: de-duplicate security release processes
sam-github Dec 16, 2019
b193142
benchmark: use let instead of var in crypto
dnlup Dec 30, 2019
b916035
http2: make HTTP2ServerResponse more streams compliant
ronag Dec 14, 2019
d831dc1
assert: implement `assert.match()` and `assert.doesNotMatch()`
BridgeAR Dec 12, 2019
dcbb97e
perf_hooks: move perf_hooks out of experimental
legendecas Dec 26, 2019
e2ef1a9
deps: V8: bump v8_embedder_string for 0e21c1e637bf
ChALkeR Dec 26, 2019
33352c2
doc: clarify role of writable.cork()
GKJCJG Nov 12, 2019
5bf2772
stream: group all properties using defineProperties
antsmartian Dec 31, 2019
827d3fe
benchmark: add benchmark on async_hooks enabled http server
legendecas Dec 26, 2019
72c6460
module: unflag resolve self
guybedford Dec 17, 2019
9b7cf09
build: don't use -latomic on macOS
ryandesign Oct 23, 2019
697908e
util: improve prototype inspection using `inspect()` and `showHidden`
BridgeAR Dec 26, 2019
1057a4c
errors: support prepareSourceMap with source-maps
bcoe Dec 31, 2019
c23bbc6
tools: remove prefer-common-expectserror lint rule
cjihrig Dec 31, 2019
892e7b0
src: suppress warning in src/node_env_var.cc
HarshithaKP Dec 30, 2019
1b720aa
http: free listeners on free sockets
ronag Aug 21, 2019
d3a8088
doc: improve explanation of package.json "type" field
tamias May 1, 2019
bd6a29c
test: use spread object
franher Nov 12, 2019
a6c2502
esm: better error message for unsupported URL
Hakerh400 Dec 29, 2019
4a54f30
http: http_outgoing rename var to let and const
Nov 6, 2019
ca23511
deps: V8: backport a4545db
devnexen Dec 29, 2019
cc44325
doc: update REPL documentation to instantiate the REPL
BridgeAR Dec 12, 2019
dba2ab7
doc: use code markup/markdown in headers
BridgeAR Jan 1, 2020
18acacc
https: prevent options object from being mutated
vighnesh153 Jan 2, 2020
d771221
n-api: keep napi_env alive while it has finalizers
addaleax Dec 30, 2019
7b696fe
doc: remove extra backtick
cjihrig Jan 4, 2020
4b2d8df
lib: do not catch user errors
BridgeAR Jan 1, 2020
ae58c97
perf_hooks: use for...of
trivikr Dec 21, 2019
1527796
lib: replace Set.prototype with SetPrototype primordial
Sebastien-Ahkrin Jan 2, 2020
0b8eaf2
lib: replace WeakMap global by the primordials
Sebastien-Ahkrin Jan 2, 2020
542aae4
lib: replace WeakSet global by the primordials
Sebastien-Ahkrin Jan 2, 2020
3f21ad6
lib: replace Set global by the primordials
Sebastien-Ahkrin Jan 2, 2020
f268621
lib: replace use of Error with primordials
Sebastien-Ahkrin Jan 2, 2020
20ecb5d
lib: replace Map global by the primordials
Sebastien-Ahkrin Jan 2, 2020
b5a71a4
http2: set default enableConnectProtocol to 0
ZYSzys Jan 3, 2020
21d9664
test: change buffer offset to accommodate V8 BackingStore
thangktran Dec 24, 2019
5fccb50
benchmark: use let instead of var in dgram
dnlup Jan 3, 2020
614b074
wasi: refactor destructuring object on constructor
himself65 Jan 4, 2020
42d36dc
lib: move initialization of APIs for changing process state
addaleax Jan 3, 2020
1a552f6
2020-01-07, Version v13.6.0 (Current)
BridgeAR Jan 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
events: allow monitoring error events
Installing an error listener has a side effect that emitted errors are
considered as handled. This is quite bad for monitoring/logging tools
which tend to be interested in errors but don't want to cause side
effects like swallow an exception.

There are some workarounds in the wild like monkey patching emit or
remit the error if monitoring tool detects that it is the only listener
but this is error prone and risky.

This PR allows to install a listener to monitor errors with the side
effect to consume the error. To avoid conflicts with other events it
exports a symbol on EventEmitter which owns this special meaning.

Refs: open-telemetry/opentelemetry-js#225

PR-URL: #30932
Refs: open-telemetry/opentelemetry-js#225
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Flarna authored and BridgeAR committed Jan 3, 2020
commit f570de8ea9893ca424621ed22fbf8a2dfe8493e3
25 changes: 25 additions & 0 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ myEmitter.emit('error', new Error('whoops!'));
// Prints: whoops! there was an error
```

It is possible to monitor `'error'` events without consuming the emitted error
by installing a listener using the symbol `errorMonitor`.

```js
const myEmitter = new MyEmitter();
myEmitter.on(EventEmitter.errorMonitor, (err) => {
MyMonitoringTool.log(err);
});
myEmitter.emit('error', new Error('whoops!'));
// Still throws and crashes Node.js
```

## Capture Rejections of Promises

> Stability: 1 - captureRejections is experimental.
Expand Down Expand Up @@ -348,6 +360,19 @@ the event emitter instance, the event’s name and the number of attached
listeners, respectively.
Its `name` property is set to `'MaxListenersExceededWarning'`.

### EventEmitter.errorMonitor
<!-- YAML
added: REPLACEME
-->

This symbol shall be used to install a listener for only monitoring `'error'`
events. Listeners installed using this symbol are called before the regular
`'error'` listeners are called.

Installing a listener using this symbol does not change the behavior once an
`'error'` event is emitted, therefore the process will still crash if no
regular `'error'` listener is installed.

### emitter.addListener(eventName, listener)
<!-- YAML
added: v0.1.26
Expand Down
14 changes: 12 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const {
} = require('internal/util/inspect');

const kCapture = Symbol('kCapture');
const kErrorMonitor = Symbol('events.errorMonitor');

function EventEmitter(opts) {
EventEmitter.init.call(this, opts);
Expand Down Expand Up @@ -83,6 +84,13 @@ ObjectDefineProperty(EventEmitter, 'captureRejections', {
enumerable: true
});

ObjectDefineProperty(EventEmitter, 'errorMonitor', {
value: kErrorMonitor,
writable: false,
configurable: true,
enumerable: true
});

// The default for captureRejections is false
ObjectDefineProperty(EventEmitter.prototype, kCapture, {
value: false,
Expand Down Expand Up @@ -256,9 +264,11 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
let doError = (type === 'error');

const events = this._events;
if (events !== undefined)
if (events !== undefined) {
if (doError && events[kErrorMonitor] !== undefined)
this.emit(kErrorMonitor, ...args);
doError = (doError && events.error === undefined);
else if (!doError)
} else if (!doError)
return false;

// If there is no 'error' event listener then throw.
Expand Down
32 changes: 32 additions & 0 deletions test/parallel/test-event-emitter-error-monitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const EventEmitter = require('events');

const EE = new EventEmitter();
const theErr = new Error('MyError');

EE.on(
EventEmitter.errorMonitor,
common.mustCall(function onErrorMonitor(e) {
assert.strictEqual(e, theErr);
}, 3)
);

// Verify with no error listener
common.expectsError(
() => EE.emit('error', theErr), theErr
);

// Verify with error listener
EE.once('error', common.mustCall((e) => assert.strictEqual(e, theErr)));
EE.emit('error', theErr);


// Verify it works with once
process.nextTick(() => EE.emit('error', theErr));
assert.rejects(EventEmitter.once(EE, 'notTriggered'), theErr);

// Only error events trigger error monitor
EE.on('aEvent', common.mustCall());
EE.emit('aEvent');