Skip to content

events: fix addAbortListener for aborted signals - #65640

Open
lazerg wants to merge 1 commit into
nodejs:mainfrom
lazerg:fix/issue-65637-abort-listener-disposal
Open

events: fix addAbortListener for aborted signals#65640
lazerg wants to merge 1 commit into
nodejs:mainfrom
lazerg:fix/issue-65637-abort-listener-disposal

Conversation

@lazerg

@lazerg lazerg commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

When addAbortListener() is given a signal that is already aborted, it queues listener() with no arguments and leaves the returned disposable empty. So the callback gets undefined where every other path hands it the abort event, and disposing before the microtask runs does not stop it from firing.

The aborted branch now builds a trusted abort event with the same target and dispatch state the real listener would see, and its dispose handler cancels the pending microtask.

Fixes #65637

@nodejs-github-bot nodejs-github-bot added events Issues and PRs related to EventEmitter and the events module. needs-ci PRs that need a full CI run. labels Aug 29, 2026
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
@lazerg
lazerg force-pushed the fix/issue-65637-abort-listener-disposal branch from 1830f2a to eca0fdb Compare August 29, 2026 08:47
@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.06%. Comparing base (2f469df) to head (eca0fdb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65640      +/-   ##
==========================================
+ Coverage   90.04%   90.06%   +0.01%     
==========================================
  Files         754      754              
  Lines      255722   255738      +16     
  Branches    48312    48311       -1     
==========================================
+ Hits       230274   230320      +46     
+ Misses      16553    16544       -9     
+ Partials     8895     8874      -21     
Files with missing lines Coverage Δ
lib/internal/event_target.js 98.80% <100.00%> (+<0.01%) ⬆️
lib/internal/events/abort_listener.js 100.00% <100.00%> (ø)

... and 29 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.

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

Labels

events Issues and PRs related to EventEmitter and the events module. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

events: addAbortListener ignores disposal and passes undefined event when signal is already aborted

2 participants