Skip to content

Commit

Permalink
test: make pass when run on Node.js >22.13
Browse files Browse the repository at this point in the history
After nodejs/node#55816, getMaxListeners() throws by default
when called on AbortSignal.
Turns out that it's not necessary to use it, just any value will do
as the test guarantees that there's a single listener anyway.
  • Loading branch information
gustavohenke committed Feb 22, 2025
1 parent 7f3efb2 commit 4ffe63b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/completion-listener.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getEventListeners, getMaxListeners } from 'events';
import { getEventListeners } from 'events';
import { TestScheduler } from 'rxjs/testing';

import { CloseEvent } from './command';
Expand Down Expand Up @@ -59,9 +59,8 @@ describe('listen', () => {

it('does not leak memory when listening for abort signals', () => {
const abortCtrl = new AbortController();
const maxListeners = getMaxListeners(abortCtrl.signal);
createController().listen(
Array.from({ length: maxListeners + 1 }, () => new FakeCommand()),
Array.from({ length: 10 }, () => new FakeCommand()),
abortCtrl.signal,
);
expect(getEventListeners(abortCtrl.signal, 'abort')).toHaveLength(1);
Expand Down

0 comments on commit 4ffe63b

Please sign in to comment.