Skip to content

test: clean up process exit listeners after each test#355

Open
Tony133 wants to merge 1 commit into
mainfrom
test/sanitize-publish-listeners
Open

test: clean up process exit listeners after each test#355
Tony133 wants to merge 1 commit into
mainfrom
test/sanitize-publish-listeners

Conversation

@Tony133

@Tony133 Tony133 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Proposal:

  • Refactored test/command-publish.test.js to properly manage and sanitize process exit listeners.

Changes:

  • Added a beforeEach hook to store the state of active process.listeners('exit') before each test execution.
  • Added an afterEach hook to purge any orphan process exit listeners registered by proxyquire sub-dependencies during the test run.

Why is this needed?

  • Some sub-dependencies mocked via proxyquire were registering persistent exit listeners on the main process without removing them. This could leak memory and pollute the Node.js process environment, potentially disrupting proper process signaling, child process management, or Inter-Process Communication (IPC) boundaries during test orchestration in strict CI pipelines. ( see error here: https://github.com/fastify/releasify/actions/runs/28734462005/job/85212333752#step:5:228)

This PR should resolve this error CI ( in Nodejs v24.18.0 ):

✖ test/command-publish.test.js (1863.675396ms)
  Error: Unable to deserialize cloned data due to invalid or unsupported version.
      at #processRawBuffer (node:internal/test_runner/runner:469:20)
      at FileTest.parseMessage (node:internal/test_runner/runner:376:29)
      at Socket.<anonymous> (node:internal/test_runner/runner:524:15)
      at Socket.emit (node:events:509:28)
      at addChunk (node:internal/streams/readable:563:12)
      at readableAddChunkPushByteMode (node:internal/streams/readable:514:3)
      at Readable.push (node:internal/streams/readable:394:5)
      at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)

@Tony133 Tony133 force-pushed the test/sanitize-publish-listeners branch from f90cb6e to 3657f65 Compare July 13, 2026 15:59
@Tony133 Tony133 force-pushed the test/sanitize-publish-listeners branch from 3657f65 to 735bc1c Compare July 13, 2026 16:04
@Tony133 Tony133 marked this pull request as ready for review July 13, 2026 16:06
@Tony133 Tony133 requested a review from Eomm July 13, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant