You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling addLogListener on ReownCore and logging with Logger of the same event level, the app throws a stack overflow (causes an infinite loop). This is probably due to an issue with the Logger package: SourceHorizon/logger#83. Since it adds a global callback, any instances of the logger will be called by the callback, including the consuming project's logger instance(s).
This causes an issue in our project, because we also use Logger as our logging tool, and calling addLogListener causes important side effects.
There are two important cases:
Logging with a Logger instance within the callback. This causes a stack overflow (callback -> logger -> callback)
Logging with a Logger instance outside the callback. This calls the callback that may not be related to ReOwn (logger -> callback). Although it does not cause a stack overflow, it creates an unintended side effect.
Although appears to be an issue with the Logger package, I chose to report it here to see how solutions could be applied.
Potential solutions:
Migrate to Logger 3.0.0 which seems to fix the issue. The callback should then be added to the local instance rather than the static one. However, 3.0.0 is not officially released, so unsure if stable to use in prod
Adding a middleware logging class that would dispatch the logs appropriately (without Logger). To prevent breaking the internal code or a major refactor, the middleware class would need to use the same method signature, perhaps extending Logger. This class would act as a wrapper to Logger that would also send the event in the callback.
Temporarily: Add a clear identifier in the log callback (e.g. [ReOwn]) so it can be filtered out in the callback Unfortunately, the addLogListener method also appends whatever is added to any log used with Logger instance, since it is global (also another problem). So this solution seems impractical.
To Reproduce
Steps to reproduce the behavior:
Create a Logger instance
Create a app kit modal instance with log level debug
Add a callback with appKitModal.core.addLogListener
Case 1:
Call debug on the logger instance within the addLogListener callback
Initialize appKitModal
Case 2:
Add a print statement in addLogListener callback
Call debug on the logger instance somewhere else in the code
Expected behavior
Case 1: The log should be logged with the logger once, and not cause a stack overflow/infinite loop
Case 2: The print statement should not print when calling debug somewhere else in the code
bawahakim
changed the title
addLogListener causes stack overflow and unintended side effects with other Logger instanceaddLogListener causes stack overflow and unintended side effects with other Logger instance
Feb 24, 2025
SDK Affected
AppKit
Describe the bug
When calling
addLogListener
onReownCore
and logging with Logger of the same event level, the app throws a stack overflow (causes an infinite loop). This is probably due to an issue with the Logger package: SourceHorizon/logger#83. Since it adds a global callback, any instances of the logger will be called by the callback, including the consuming project's logger instance(s).This causes an issue in our project, because we also use Logger as our logging tool, and calling
addLogListener
causes important side effects.There are two important cases:
Although appears to be an issue with the Logger package, I chose to report it here to see how solutions could be applied.
Potential solutions:
Temporarily: Add a clear identifier in the log callback (e.g.Unfortunately, the[ReOwn]
) so it can be filtered out in the callbackaddLogListener
method also appends whatever is added to any log used with Logger instance, since it is global (also another problem). So this solution seems impractical.To Reproduce
Steps to reproduce the behavior:
debug
appKitModal.core.addLogListener
Case 1:
debug
on the logger instance within theaddLogListener
callbackCase 2:
addLogListener
callbackdebug
on the logger instance somewhere else in the codeExpected behavior
Case 1: The log should be logged with the logger once, and not cause a stack overflow/infinite loop
Case 2: The print statement should not print when calling
debug
somewhere else in the codeReproducible code
The text was updated successfully, but these errors were encountered: