Skip to content

leaks signal listeners in Node.js #881

@boneskull

Description

@boneskull

Expected Behavior

Given test.mjs

import {$} from 'zx';

const ac = new AbortController();
const {signal} = ac;

for (let i = 0; i < 10; i++) {
  $.sync({signal})``; // does nothing
  // $.sync({signal})`pwd`; // same result
}

// no MaxListenersExceededWarning

I would expect the signal listener to be released after the subprocess has ended.

Actual Behavior

Executing node test.mjs results in:

(node:49248) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners
added to [AbortSignal]. MaxListeners is 10. Use events.setMaxListeners() to increase limit

Not specific to sync.

Steps to Reproduce

  1. Create test.mjs with the example code
  2. Run it via node --trace-warnings test.mjs
  3. Observe a lovely stack trace blaming zx/build/vendor-core.cjs:404:25

Specifications

  • zx version: v8.1.5
  • Platform: macos
  • Runtime: node

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions