Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid "possible EventEmitter memory leak detected" warning #6789

Merged
merged 3 commits into from
Dec 24, 2024

Conversation

n1ru4l
Copy link
Collaborator

@n1ru4l n1ru4l commented Dec 20, 2024

Description

I noticed the "possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit." warning within our Hive GraphQL API service, which leads back to setting up too many event listeners here.

While the warning is not a real issue, we should avoid triggering it.

Extra from @ardatan ;

  • Single helper for AbortSignal event listener registration so it can be used by other packages, too.
  • Replace if(signal.aborted) throw logic with signal?.throwIfAborted
  • Check if there is only one listener registered to AbortSignal in tests
  • Shared rejection promise for AbortSignal instead of creating it multiple times

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Existing tests pass, so the provided functionality stays the same.

Copy link

changeset-bot bot commented Dec 20, 2024

🦋 Changeset detected

Latest commit: 7cec9a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@graphql-tools/utils Minor
@graphql-tools/executor Patch
@graphql-tools/graphql-tag-pluck Patch
@graphql-tools/import Patch
@graphql-tools/links Patch
@graphql-tools/load Patch
@graphql-tools/merge Patch
@graphql-tools/mock Patch
@graphql-tools/node-require Patch
@graphql-tools/relay-operation-optimizer Patch
@graphql-tools/resolvers-composition Patch
@graphql-tools/schema Patch
@graphql-tools/apollo-engine-loader Patch
@graphql-tools/code-file-loader Patch
@graphql-tools/git-loader Patch
@graphql-tools/github-loader Patch
@graphql-tools/graphql-file-loader Patch
@graphql-tools/json-file-loader Patch
@graphql-tools/module-loader Patch
@graphql-tools/url-loader Patch
@graphql-tools/executor-apollo-link Patch
@graphql-tools/executor-envelop Patch
@graphql-tools/executor-legacy-ws Patch
@graphql-tools/executor-urql-exchange Patch
@graphql-tools/executor-yoga Patch
graphql-tools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@n1ru4l n1ru4l requested review from ardatan and saihaj December 20, 2024 13:07
@n1ru4l n1ru4l changed the title fix: possible EventEmitter memory leak detected fix: avoid "possible EventEmitter memory leak detected" warning Dec 20, 2024
@n1ru4l n1ru4l force-pushed the fix-max-listener-warning branch from 30026af to cfab60c Compare December 20, 2024 13:29
@theguild-bot
Copy link
Collaborator

theguild-bot commented Dec 20, 2024

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-tools/executor 1.3.10-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-apollo-link 1.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-envelop 3.0.17-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-legacy-ws 1.1.8-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-urql-exchange 1.0.10-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-yoga 3.0.17-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/graphql-tag-pluck 8.3.10-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
graphql-tools 9.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/import 7.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/links 9.0.18-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/load 8.0.10-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/apollo-engine-loader 8.0.10-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/code-file-loader 8.1.11-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/git-loader 8.0.15-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/github-loader 8.0.10-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/graphql-file-loader 8.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/json-file-loader 8.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/module-loader 8.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/url-loader 8.0.21-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/merge 9.0.15-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/mock 9.0.12-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/node-require 7.0.10-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/relay-operation-optimizer 7.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/resolvers-composition 7.0.9-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/schema 10.0.14-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎
@graphql-tools/utils 10.7.0-alpha-20241224080220-7cec9a36c8869567ca685def6970f80d29f8b7f5 npm ↗︎ unpkg ↗︎

@ardatan
Copy link
Owner

ardatan commented Dec 23, 2024

See #6793

  • We can export a helper to register listeners to the signal so we can benefit this in other packages; Hive Gateway etc.

* Single place for AbortSignal listeners

* Fix

* ..

* Lets go

* Small improvement

* Changeset for utils
@ardatan ardatan requested a review from dotansimha December 24, 2024 07:57
Copy link
Contributor

github-actions bot commented Dec 24, 2024

💻 Website Preview

The latest changes are available as preview in: https://7cd867a4.graphql-tools.pages.dev

@ardatan ardatan merged commit 2c70d27 into master Dec 24, 2024
14 checks passed
@ardatan ardatan deleted the fix-max-listener-warning branch December 24, 2024 11:58
@slagiewka
Copy link

FYI node 23.5.0 has this warning disabled for AbortSignal nodejs/node#55816. It's also scheduled to be in 22.13.0 with the backport already done nodejs/node@81c94a32e4

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.

6 participants