Skip to content

Fix a handful of minor bugs with the JVM implementation. - #35

Merged
KetanReddy merged 2 commits into
mainfrom
jvm-bugs
Oct 15, 2026
Merged

KetanReddy merged 2 commits into
mainfrom
jvm-bugs

Conversation

@KetanReddy

Copy link
Copy Markdown
Member

Summary

Fixes three bugs in the JVM devtools bindings that stop a JVM Player from talking to a devtools client.

DevtoolsPlugin.registerMessenger passed a function to JS

Messenger implements MessageHandler ((Event) -> Unit), so the runtime encoded it as a JS function rather than the messenger instance. The JS plugin then failed with TypeError: messenger.sendMessage is not a function. registerMessenger now passes the backing JS instance (messenger.node).

The JS Messenger received the context as an ordinal

The runtime format encodes enums by ordinal, so Messenger.Options.context reached JS as 0 instead of "player"/"devtools". Every outgoing event carried the wrong context, and the "ignore messages from the same context" check never matched. Options now serializes context as its serial name through a private backing property, following the same pattern as sendMessage and logger.

Typed events dropped target

Event subclasses didn't model target, so any event that went through the JVM (sendMessage, messageCallback) lost it. That broke targeted delivery, for example MESSENGER_EVENT_BATCH replays to a newly connected peer. This adds an optional target: String? = null to TransactionMetaData, all typed events and UnknownEvent.

API changes

  • New target property on TransactionMetaData and on each event class, as a new trailing constructor parameter that defaults to null. Kotlin source callers are unaffected, but already-compiled callers of the event constructors or copy() need a recompile.
  • patch
  • minor
  • major

Release Notes

Fixes three bugs in the JVM devtools bindings that stop a JVM Player from talking to a devtools client.

@KetanReddy KetanReddy self-assigned this Oct 15, 2026
@KetanReddy
KetanReddy requested a review from a team as a code owner October 15, 2026 19:35
@KetanReddy KetanReddy added the patch Increment the patch version when merged label Oct 15, 2026
@AngelaVilladiego

Copy link
Copy Markdown
Collaborator

LGTM, but Claude did raise the following potential non-blocking flags; feel free to take with a pinch of salt:

  1. messenger.node before apply() crashes. instance is lateinit, so calling registerMessenger before messenger.apply(runtime) throws UninitializedPropertyAccessException. A messenger applied to a different runtime than the plugin would also misbehave. Android is fine (AndroidDevtoolsPlugin.kt:57-61 applies it to corePlugin.node.runtime first). A guard on the existing isInstantiated that throws a PlayerException would give a clear error.
  2. Only one call site is fixed. The underlying trap is that Messenger is both a Function and a NodeWrapper, and the encoder picks Function. Any future code passing a Messenger into the runtime hits it again. A comment or test would help.

I'm fine to approve once you confirm about the above!

@AngelaVilladiego AngelaVilladiego left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@KetanReddy
KetanReddy enabled auto-merge October 15, 2026 20:42
@KetanReddy
KetanReddy merged commit 9d5e6c9 into main Oct 15, 2026
8 checks passed
@KetanReddy
KetanReddy deleted the jvm-bugs branch October 15, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants