Random Invalid key event specified in XML Error

Hi all, In our setup, we define a custom key event (e.g. RS.CUSTOM_EVENT) in
WASM using C++ call SimConnect_MapClientEventToSimEvent in one of the
gauges. Then, another HTML gauge uses SetSimVarValue to “transmit/set” the
event with some value. Now this works almost every time, except in very few
cases, where upon loading the aircraft, the console will report “Invalid key
event specified in XML: RS.CUSTOM_EVENT” with “Invalid variable name:
RS.CUSTOM_EVENT”. When this happens, the specified event will not work in any
subsequent call to SetSimVarValue. I’ve not found a way to reproduce this
consistently, but it happens 50% of the time. If I then reload the aircraft
(e.g. with “Quick Reload” in behavior debug) the error does not happen again
and everything works. My questions are: 1. What do these 2 messages mean?
Because I’ve not had anywhere in XML (e.g. model behaviors) that make any
reference to the event. The only 2 places that reference this event are the
C++ WASM code and the Javascript call. 2. What may be causing this and how
can we work around this? Is this caused by maybe the javascript side calling
the SetSimVar too soon? Is there some checking method on the javascript side I
can use to ensure this error doesn’t happen? Thanks!