jeffreylanters / react-unity-webgl

React Unity WebGL provides a modern solution for embedding Unity WebGL builds in your React Application while providing advanced APIs for two way communication and interaction between Unity and React.
https://react-unity-webgl.dev
Apache License 2.0
1.73k stars 163 forks source link

Error event listener doesn't appear to be working #506

Closed rajputav closed 1 year ago

rajputav commented 1 year ago

Please avoid duplicates

Language and Compiler

Vanilla JavaScript

What environment are you using?

Server Side Renderering

When does your problem occur?

When the Unity App is running

What does your problem relate to?

The problem seems Module related

React-Unity-WebGL Version

9.2.1

React Version

17.0.2

Unity Version

2022.2.9f1

What happened?

Version 8.x.x. of the package supported error listeners: https://github.com/jeffreylanters/react-unity-webgl/blob/7b7aac91690b7cd3ed7968e82b20c9f732b04c43/documentation/versioned_docs/version-8.x.x/api/on-error.md#L4 .

When trying to implement an error listener on Verizon 9.2.1 using the addEventListener(‘error’) API, it appears that no errors are caught detected. Is this intended behavior or is there an undocumented API that captures the proper usage of the error event listener?

Thanks!

Reproducible test case

No response

Would you be interested in contributing a fix?

jeffreylanters commented 1 year ago

Hi Avinash! Sadly Unity doesn't expose caught errors that well, they're instead using window.error to dump their errors to the console without any proper way to interfere. Previous versions of the module intercepted these error messages, but this was proven to be too hacky of a solution. -- So until Unity implements proper error handling, there isn't anything we can do really.