Skip to content

Add logging of the mapping function in MapTaskObservable#2030

Open
halotukozak wants to merge 3 commits intomonix:mainfrom
AVSystem:improve-map-task-invalid-state-logging-to-upstream
Open

Add logging of the mapping function in MapTaskObservable#2030
halotukozak wants to merge 3 commits intomonix:mainfrom
AVSystem:improve-map-task-invalid-state-logging-to-upstream

Conversation

@halotukozak
Copy link
Copy Markdown

Original contribution from the AVSystem's fork made by @mikkolaj
AVSystem#2

MapTaskObservable reports invalid state on some environments.

We weren't able to reproduce it synthetically, so in an attempt to gain better understanding of the error (and it's extent) I suggest logging the function used to process each element of the Observable when such failure occurs.

Copilot AI review requested due to automatic review settings April 10, 2026 08:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances diagnostics for rare MapTaskObservable state-machine failures by adding information about the mapping function to the reported IllegalStateException, to help reproduce/debug environment-specific invalid state reports.

Changes:

  • Extend the invalid-state error message in MapTaskObservable to include the executed mapping function (f).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 351 to +353
s"State $state in the Monix MapTask.$method implementation is invalid, " +
"due to either a broken Subscriber implementation, or a bug, " +
"please open an issue, see: https://monix.io"
s"please open an issue, see: https://monix.io. Executed function: $f"
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including Executed function: $f will call toString on a user-supplied function and embed it in an exception reported via scheduler.reportFailure, which can leak sensitive captured values and is often not very informative for anonymous lambdas (e.g., <function1>). Consider logging a safer, more diagnostic identifier (e.g., f.getClass.getName plus System.identityHashCode(f)), and keep the URL unpunctuated (avoid the trailing . after https://monix.io so the link copies correctly).

Copilot uses AI. Check for mistakes.
@mikkolaj
Copy link
Copy Markdown

We stopped observing this behavior after introducing changes from #2031, so adding this logging might be unnecessary now.

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.

3 participants