-
Notifications
You must be signed in to change notification settings - Fork 5
Unnecessary register of uncaughtException handlers #4
Description
At the beginning, I will mention that I'm aware that the main source of the issue is node-xmllint however it looks that node-xmllint is not maintained anymore, so any fix there would require creating a fork or merging its code directly here.
I noticed in my application that handle SAML that I got node warnings:
(node:1) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit
After deeper investigations, I found that uncaughtException listeners are registered by node-xmllint called by samlify-node-xmllint.
node-xmllint has been made as a conversion of libxml2 using Emscripten. Emscripten contains a feature that it auto-register these handlers for each compilation. In the newer version, it is possible to disable it:
emscripten-core/emscripten#7855
Why is this problematic?
- Library produce undocumented side effect
- As a registered handler is terminating the application, it might block other custom handlers from running (for example user might want to connect the logger to this event before closing the app, which might not be called due to handlers registered by node-xmllint)
- Handler is registered with each reference to this library which might lead to memory leaks.