Skip to content

stream: deprecate legacy prependListener fallback#62435

Open
karan-lrn wants to merge 1 commit intonodejs:mainfrom
karan-lrn:stream-remove-prependlistener-hack
Open

stream: deprecate legacy prependListener fallback#62435
karan-lrn wants to merge 1 commit intonodejs:mainfrom
karan-lrn:stream-remove-prependlistener-hack

Conversation

@karan-lrn
Copy link
Copy Markdown
Contributor

The prependListener method has been available on EventEmitter since Node.js v6.0.0 (April 2016). The fallback code that manipulated the internal _events object is no longer necessary.

This also removes tests that explicitly tested the fallback behavior.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Mar 25, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.69%. Comparing base (0d7e4b1) to head (dea878a).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #62435    +/-   ##
========================================
  Coverage   89.68%   89.69%            
========================================
  Files         676      678     +2     
  Lines      206738   207206   +468     
  Branches    39594    39726   +132     
========================================
+ Hits       185414   185854   +440     
+ Misses      13467    13447    -20     
- Partials     7857     7905    +48     
Files with missing lines Coverage Δ
lib/internal/streams/legacy.js 94.89% <100.00%> (+0.44%) ⬆️

... and 66 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@karan-lrn
Copy link
Copy Markdown
Contributor Author

cc @nodejs/streams @mcollina @ronag

This PR removes the legacy prependListener fallback in lib/internal/streams/legacy.js. The fallback code manipulated the internal _events object to support Node.js versions before v6.0.0 (April 2016) where prependListener didn't exist.

Since Node.js v6 has been EOL for over 8 years, this cleanup removes ~15 lines of unnecessary code and the associated tests that explicitly tested the fallback behavior.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to deprecate this first

@karan-lrn karan-lrn force-pushed the stream-remove-prependlistener-hack branch from 73f182e to dbb2a5f Compare March 27, 2026 11:04
@karan-lrn
Copy link
Copy Markdown
Contributor Author

Hey @mcollina
Thanks for the feedback! I've updated the PR to add a runtime deprecation (DEP0205) instead of removing the code outright.

The deprecation warning now fires when piping to an EventEmitter that lacks the prependListener method. The fallback behavior is preserved for now, giving users time to migrate.

Once this lands and goes through a few releases, we can remove the fallback code entirely.

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
@karan-lrn karan-lrn force-pushed the stream-remove-prependlistener-hack branch from dbb2a5f to dea878a Compare March 27, 2026 11:07
@karan-lrn karan-lrn requested a review from mcollina March 27, 2026 11:10
@karan-lrn karan-lrn changed the title stream: remove legacy prependListener fallback stream: deprecate legacy prependListener fallback Mar 27, 2026
@mcollina mcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Mar 27, 2026
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 27, 2026
@nodejs-github-bot

This comment was marked as outdated.

@aduh95 aduh95 removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 28, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants