Describe the bug
When deserialization the result of a JS function using a UnitSerializer, Hermes implementation discards the result, but J2V8 throws an error trying to deserialize the result into a Unit
To Reproduce
The following are two tests that run the same JS function and deserialize using the UnitSerializer. One is formatted to work with the J2V8 runtime, the other with Hermes. The Hermes test will pass and the J2V8 test will throw an exception:
J2V8:
@Test
fun `test unit`() {
v8.evaluateInJSThreadBlocking(runtime) {
val jsFunc = v8.executeObjectScript("""() => ({ "prop": "value" })""").v8Function
val invokable = jsFunc.toInvokable(format, v8Object, format.serializer<Unit>())
assertNotNull(invokable)
assertEquals(Unit, invokable.invoke())
}
}
Hermes:
@Test
fun `test unit`() {
runtime.evaluateInJSThreadBlocking {
val jsFunc = runtime.evaluateJavaScript("""() => ({ "prop": "value" })""").asObject(runtime).asFunction(runtime)
val invokable = jsFunc.toInvokable(format, jsFunc, format.serializer<Unit>())
assertNotNull(invokable)
assertEquals(Unit, invokable.invoke())
}
}
Expected behavior
Functionality should be the same across runtimes. Keeping the J2V8 functionality may be preferred to ensure that JS function results aren't accidentally being thrown out.
Environment:
Describe the bug
When deserialization the result of a JS function using a
UnitSerializer, Hermes implementation discards the result, but J2V8 throws an error trying to deserialize the result into aUnitTo Reproduce
The following are two tests that run the same JS function and deserialize using the
UnitSerializer. One is formatted to work with the J2V8 runtime, the other with Hermes. The Hermes test will pass and the J2V8 test will throw an exception:J2V8:
Hermes:
Expected behavior
Functionality should be the same across runtimes. Keeping the J2V8 functionality may be preferred to ensure that JS function results aren't accidentally being thrown out.
Environment: