Skip to content

Conversation

@stainless-app
Copy link
Contributor

@stainless-app stainless-app bot commented Feb 6, 2026

Automated Release PR

4.9.1 (2026-02-06)

Full Changelog: v4.9.0...v4.9.1

Bug Fixes

  • client: avoid removing abort listener too early (d3af18e)

This pull request is managed by Stainless's GitHub App.

The semver version number is based on included commit messages. Alternatively, you can manually set the version number in the title of this pull request.

For a better experience, it is recommended to use either rebase-merge or squash-merge when merging this pull request.

🔗 Stainless website
📚 Read the docs
🙋 Reach out for help or questions

@stainless-app
Copy link
Contributor Author

stainless-app bot commented Feb 6, 2026

🧪 Testing

To try out this version of the SDK, run:

npm install 'https://pkg.stainless.com/s/supermemory-new-typescript/d3af18e05bbcc085d7fef21dace557bf07011c7b/dist.tar.gz'

Expires at: Sun, 08 Mar 2026 05:19:53 GMT
Updated at: Fri, 06 Feb 2026 05:19:53 GMT

} finally {
clearTimeout(timeout);
if (signal) signal.removeEventListener('abort', abort);
}
Copy link

Choose a reason for hiding this comment

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

Bug: Removing removeEventListener in the finally block causes a memory leak, as listeners on a reused external signal are not cleaned up if the request completes without being aborted.
Severity: HIGH

Suggested Fix

Restore the signal.removeEventListener('abort', abort) call inside the finally block. This ensures the listener is always cleaned up after the request finishes, regardless of whether it was aborted, preventing memory leaks when an AbortSignal is reused.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/client.ts#L596

Potential issue: The removal of `signal.removeEventListener('abort', abort)` from the
`finally` block introduces a memory leak. The `abort` event listener is added to the
external `signal` with the `{ once: true }` option, which only removes the listener
after it fires. If a request completes successfully or times out without the external
signal being aborted, the listener is never removed. When the same `AbortSignal` is
reused across multiple requests, which is a valid pattern, these orphaned listeners
accumulate on the signal object, leading to a memory leak and potentially a
`MaxListenersExceededWarning` in Node.js environments.

Did we get this right? 👍 / 👎 to inform future reviews.

@stainless-app stainless-app bot merged commit 27196e9 into main Feb 6, 2026
8 checks passed
@stainless-app
Copy link
Contributor Author

stainless-app bot commented Feb 6, 2026

🤖 Release is at https://github.com/supermemoryai/sdk-ts/releases/tag/v4.9.1 🌻

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants