Skip to content

Commit

Permalink
Remove EventEmitter max listeners warning
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed May 7, 2024
1 parent 599f6d5 commit fdda27f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.11.2 (May XX, 2024)
- Updated internal use of the SDK client to remove EventEmitter memory leak warnings. These warnings are emitted when using multiple hooks and components from the SDK simultaneously, but they do not indicate an actual memory leak and are irrelevant for SDK usage (Related to https://github.com/splitio/react-client/issues/191).

1.11.1 (March 26, 2024)
- Bugfixing - Added tslib as an explicit dependency to avoid issues with some package managers that don't resolve it automatically as a transitive dependency from @splitsoftware/splitio-commons (Related to issue https://github.com/splitio/javascript-client/issues/795).

Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export function getSplitClient(factory: SplitIO.IBrowserSDK, key?: SplitIO.Split

// Handle client lastUpdate
if (client.lastUpdate === undefined) {
// Remove EventEmitter warning emitted when using multiple SDK hooks or components.
// Unlike JS SDK, users don't need to use the client directly and so the warning is not relevant.
client.setMaxListeners(0);

const updateLastUpdate = () => {
const lastUpdate = Date.now();
client.lastUpdate = lastUpdate > client.lastUpdate ? lastUpdate : client.lastUpdate + 1;
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"include": ["src"],
"include": [
"src"
],
"exclude": [
"./src/__tests__",
"umd.ts",
Expand Down

0 comments on commit fdda27f

Please sign in to comment.