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

Repeated test error: Possible EventEmitter memory leak detected #2783

Closed
philrz opened this issue Jun 16, 2023 · 2 comments · Fixed by #2785
Closed

Repeated test error: Possible EventEmitter memory leak detected #2783

philrz opened this issue Jun 16, 2023 · 2 comments · Fixed by #2785
Assignees
Labels
test Creating/improving test automation

Comments

@philrz
Copy link
Contributor

philrz commented Jun 16, 2023

Repro is with Zui commit b7dbd16 (associated with #2759).

While debugging other Zui test failures recently, I've been distracted by this big burst of errors that consistently appears when I run yarn test.

$ yarn test 2>&1 | grep MaxListenersExceededWarning
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 second-instance listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 web-contents-created listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 open-url listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 activate listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 before-quit listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 will-quit listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 result-selection-change listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 clearPins listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 toggleLeftSidebar listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 toggleRightSidebar listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 showPreferences listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 showExportResults listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 back listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 forward listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 closeTab listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 windows:newSearchTab listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 globalStore:dispatch listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 showReleaseNotes listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 toggleHistogram listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 runCommand listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54128) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 detail-window-args listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 second-instance listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 web-contents-created listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 open-url listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 activate listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 before-quit listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 will-quit listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 result-selection-change listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 clearPins listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 toggleLeftSidebar listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 toggleRightSidebar listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 showPreferences listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 showExportResults listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 back listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 forward listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 closeTab listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 windows:newSearchTab listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 globalStore:dispatch listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 showReleaseNotes listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 toggleHistogram listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 runCommand listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 detail-window-args listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
(node:54125) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 second-instance listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
(node:54126) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 second-instance listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit

This doesn't make the tests fail and for all I know they could be quite benign. However, their volume and mention of a possible memory leak gave me reason to be concerned that there could be an actual problem behind them and that this could somehow be contributing to the failures we see more often when CI tuns in GitHub Actions since those Runner hosts are typically quite resource constrained. If investigations find that there's not a real bug here, then maybe we could find a way to silence them or present them as harmless. I don't personally know anything about EventEmitter but my brief web search led me to this link where the folks posting in the thread caution that just increasing the limit is often not the appropriate course of action and that there very likely is a legit root problem that's worth fixing.

Note that the commit b7dbd16 where I've just reproduced the issue is associated with #2759, which was a major refactor. I narrowed down through binary search that this was the point at which this message started appearing so frequently. At commit 7363dee that came right before I only see one of these messages.

$ yarn test 2>&1 | grep MaxListenersExceededWarning
(node:54628) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 second-instance listeners added to [MockApp]. Use emitter.setMaxListeners() to increase limit
@philrz philrz added the test Creating/improving test automation label Jun 16, 2023
@jameskerr
Copy link
Member

I do have a hint at what this might be. We mock the IPC calls between the main process and the renderer process in tests. They probably don't get torn down between tests or reset.

@philrz
Copy link
Contributor Author

philrz commented Jun 30, 2023

Verified in Zui commit de25266.

The concerning messages are gone from the yarn test output.

$ yarn test 2>&1 | grep MaxListenersExceededWarning
[no output]

Here's a look at the full/tidier yarn test output at that commit.

$ yarn test
 PASS  src/js/state/Queries/queries.test.ts
 PASS  src/js/state/Tabs/test.ts
 PASS  src/js/api/pools/pools-api.test.ts
 PASS  src/js/components/Login.test.tsx
 PASS  src/app/core/links.test.ts
 PASS  src/app/features/right-pane/versions-section.test.tsx
 PASS  src/js/lib/date.test.ts
 PASS  src/js/components/ErrorNotice.test.tsx
 PASS  src/app/release-notes/test.tsx
 PASS  src/electron/ops/import-queries-op.test.ts
 PASS  src/js/state/stores/get-persistable.test.ts
 PASS  src/js/components/Preferences/Preferences.test.tsx
 PASS  src/js/state/Chart/test.ts
 PASS  src/electron/start.test.ts
 PASS  src/js/state/Modal/test.ts
 PASS  src/js/state/Queries/test.ts
 PASS  src/js/state/Lakes/test.ts
 PASS  src/js/state/Notice/test.ts
 PASS  src/js/state/LogDetails/test.ts
 PASS  src/electron/windows/window-manager.test.ts
 PASS  src/electron/session.test.ts
 PASS  src/js/state/Tabs/history.test.ts
 PASS  src/js/state/Launches/test.ts
 PASS  src/js/state/Toolbars/test.ts
 PASS  src/js/state/Errors/test.ts
 PASS  src/js/state/ConfigPropValues/test.ts
 PASS  src/js/state/Current/test.ts
 PASS  src/js/models/time.test.ts
 PASS  src/js/state/QueryVersions/query-versions.test.ts
 PASS  src/js/state/TabHistories/test.ts
 PASS  src/js/state/LakeStatuses/test.ts
 PASS  src/app/core/format.test.ts
 PASS  src/js/models/AppError.test.ts
 PASS  src/js/lib/file.test.ts
 PASS  src/electron/boot.test.ts
 PASS  src/ppl/detail/util/formatDur.test.ts
 PASS  src/js/stdlib/object.test.ts
 PASS  src/js/state/migrations/202101210823_renameToWorkspace.test.ts
 PASS  src/js/lib/transaction.test.ts
 PASS  src/electron/reset-state.test.ts
 PASS  src/js/state/migrations/202005261448_setInvestigationSpaceToNameAndId.test.ts
 PASS  src/js/models/program.test.ts
 PASS  src/core/when/parser.test.ts
 PASS  src/zui-kit/core/list-view/list-view-api.test.ts
 PASS  src/app/query-home/search-area/pins/time-range-pin/get-time-preview.test.ts
 PASS  src/electron/autoUpdater.test.ts
 PASS  src/js/state/migrations/202005271240_setHistorySpaceToNameAndId.test.ts
 PASS  src/electron/window-manager-init.test.ts
 PASS  src/js/lib/compact.test.ts
 PASS  src/js/lib/bounded.test.ts
 PASS  src/js/lib/obj.test.ts
 PASS  src/js/state/migrations/202008031645_removeViewerSlice.test.ts
 PASS  src/js/lib/move.test.ts
 PASS  src/js/state/migrations/202007091803_forceLeftSidebarDefaultOpen.test.ts
 PASS  src/js/state/migrations/202007140829_defaultColumnHeadersToAuto.test.ts
 PASS  src/js/lib/MouseoverWatch.test.ts
 PASS  src/js/state/migrations/202008121645_moveDataFromSearchToCurrent.test.ts
 PASS  src/js/state/migrations/202110050923_moveSidebarStateToAppearance.test.ts
 PASS  src/js/state/migrations/202009231326_removeLogDetails.test.ts
 PASS  src/js/state/migrations/202110150837_querylibFolders.test.ts
 PASS  src/js/state/migrations/202005181158_spacesStateId.test.ts
 PASS  src/js/state/migrations/202103051447_convertHistoryToUrls.test.ts
 PASS  src/js/state/migrations/202103051428_removeSearchBarFields.test.ts
 PASS  src/js/state/migrations/202008271352_addTargetToSearchRecord.test.ts
 PASS  src/js/state/migrations/202012011232_sidebarSections.test.ts
 PASS  src/js/lib/Array.test.ts
 PASS  src/js/state/migrations/202104291255_dropSpaces.test.ts
 PASS  src/js/state/migrations/202111111659_prependWorkspaceProtocol.test.ts
 PASS  src/app/core/models/abortables.test.ts
 PASS  src/js/models/relTime.test.ts
 PASS  src/js/state/migrations/202006091248_moveSidebarViewToTabLayout.test.ts
 PASS  src/js/state/migrations/202103011928_adjustWindowsNetworkingActivityQuery.test.ts
 PASS  src/js/state/migrations/202010191355_addConnectionNameDefault.test.ts
 PASS  src/js/state/migrations/202302161437_addLayoutDefaults.test.ts
 PASS  src/js/state/migrations/202009121941_refactorInvestigations.test.ts
 PASS  src/js/state/migrations/202107271608_movePreferences.test.ts
 PASS  src/js/state/migrations/202011060944_removeClustersStatus.test.ts
 PASS  src/js/state/migrations/202206280841_queriesWithVersions.test.ts
 PASS  src/js/state/migrations/202011141515_addSuricataRunnerPref.test.ts
 PASS  src/js/state/migrations/202101151201_addMainView.test.ts
 PASS  src/js/lib/TimeWindow.test.ts
 PASS  src/js/models/span.test.ts
 PASS  src/js/state/migrations/202007151457_addScrollPosToSearchRecord.test.ts
 PASS  src/js/state/migrations/202101201109_moveQueriesStateToGlobal.test.ts
 PASS  src/js/state/migrations/202202170834_resetInvestigationsAndTabHistories.test.ts
 PASS  src/js/state/migrations/202101291548_addAuthDefaultsToWorkspaces.test.ts
 PASS  src/js/state/migrations/202104281412_dropPacketsState.test.ts
 PASS  src/js/state/migrations/202012021127_addQuerySection.test.ts
 PASS  src/js/state/migrations/202008191031_changeZqdClusterIdToHostPort.test.ts
 PASS  src/js/state/migrations/202302131226_renameDelimeterToDelimiter.test.ts
 PASS  src/js/state/migrations/202101051511_initQueryLibrary.test.ts
 PASS  src/js/state/migrations/202005181140_searchStateSpaceId.test.ts
 PASS  src/electron/migrations.test.ts
 PASS  src/js/state/entity-slice/create-nested-entity-slice.test.ts
 PASS  src/js/zed-script/zed.test.ts
 PASS  src/js/state/migrations/202011141515_addSuricataUpdaterPref.test.ts
 PASS  src/js/state/migrations/202006231303_addLayoutSidebarSectionState.test.ts
 PASS  src/app/core/models/histories.test.ts
 PASS  src/app/features/sidebar/pools-section/group-by.test.ts
 PASS  src/js/lib/connHistoryView.test.ts
 PASS  src/js/models/poolName.test.ts
 PASS  src/electron/windows/dimens.test.ts
 PASS  src/js/state/migrations/202207270956_removeDraftQueries.test.ts
 PASS  src/js/state/migrations/202005151706_addZeekRunnerPref.test.ts
 PASS  src/js/models/UniqArray.test.ts
 PASS  src/app/query-home/title-bar/plus-one.test.ts
 PASS  src/js/state/entity-slice/create-entity-slice.test.ts
 PASS  src/app/core/pools/pool.test.ts
 PASS  src/zui-kit/core/utils/extract-cell-id.test.ts
 PASS  src/js/state/migrations/202007081719_addScrollXyToViewer.test.ts
 PASS  src/js/state/Queries/helpers.test.ts
 PASS  src/js/models/Errors.test.ts
 PASS  src/app/core/models/history.test.ts
 PASS  src/components/dialog/parse-point.test.ts
 PASS  src/js/state/Queries/parsers.test.ts
 PASS  src/ppl/zeek/logInfo.test.ts
 PASS  src/js/errors/test.ts
 PASS  src/zui-kit/core/utils/diff-keys.test.ts
 PASS  src/app/core/models/cmd-history.test.ts
 PASS  src/js/state/Results/paginate.test.ts
 PASS  src/js/models/form.test.ts

Test Suites: 121 passed, 121 total
Tests:       423 passed, 423 total
Snapshots:   4 passed, 4 total
Time:        9.94 s, estimated 10 s
Ran all test suites.

Thanks @jameskerr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Creating/improving test automation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants