Skip to content

Commit 6753c8f

Browse files
committed
stream: deprecate piping to emitters without prependListener
The prependListener method has been available on EventEmitter since Node.js v6.0.0 (April 2016). The internal fallback code that manually manipulates the _events object was intended for pre-v6 compatibility. This adds a runtime deprecation warning (DEP0205) when piping to an EventEmitter that lacks the prependListener method. The fallback behavior is preserved for now but will be removed in a future version. PR-URL: https://github.com/nodejs/node/pull/XXXXX Refs: https://github.com/nodejs/node/issues/XXXXX
1 parent ff91fea commit 6753c8f

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

doc/api/deprecations.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,6 +4563,22 @@ that have proven unresolveable. See [caveats of asynchronous customization hooks
45634563
`module.registerHooks()` as soon as possible as `module.register()` will be
45644564
removed in a future version of Node.js.
45654565
4566+
### DEP0206: Piping to emitters without `prependListener`
4567+
4568+
<!-- YAML
4569+
changes:
4570+
- version: REPLACEME
4571+
pr-url: https://github.com/nodejs/node/pull/62435
4572+
description: Runtime deprecation.
4573+
-->
4574+
4575+
Type: Runtime
4576+
4577+
Piping to an EventEmitter that does not have a `prependListener` method is
4578+
deprecated. The `prependListener` method has been available on EventEmitter
4579+
since Node.js v6.0.0. The internal fallback code that manually manipulates
4580+
the `_events` object will be removed in a future version.
4581+
45664582
[DEP0142]: #dep0142-repl_builtinlibs
45674583
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
45684584
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3

lib/internal/streams/legacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function prependListener(emitter, event, fn) {
122122
'Piping to an EventEmitter without a prependListener method is deprecated. ' +
123123
'The emitter should have a prependListener method.',
124124
'DeprecationWarning',
125-
'DEP0205',
125+
'DEP0206',
126126
);
127127
emittedPrependListenerDeprecation = true;
128128
}

test/parallel/test-event-emitter-prepend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ common.expectWarning(
4242
'DeprecationWarning',
4343
'Piping to an EventEmitter without a prependListener method is deprecated. ' +
4444
'The emitter should have a prependListener method.',
45-
'DEP0205',
45+
'DEP0206',
4646
);
4747

4848
const w = new Writable();

test/parallel/test-stream-events-prepend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ common.expectWarning(
2424
'DeprecationWarning',
2525
'Piping to an EventEmitter without a prependListener method is deprecated. ' +
2626
'The emitter should have a prependListener method.',
27-
'DEP0205',
27+
'DEP0206',
2828
);
2929

3030
const w = new Writable();

0 commit comments

Comments
 (0)