mJS asynchronous RPC handler


is it possible to add an asynchronous RPC handler using the mJS API?
From the RPC documentation it seems that the handler callback has to be synchronous.
In the C API it is possible to handle the request asynchronously.
Do I need to write a custom wrapper, or has it already been done?


The existing MJS API assumes only synchronous behavior.
The async API could be added though. If you feel like it, you could try.

Key points:

1 Like

Thanks for the pointers in the right direction! I have managed to implement the async handler.
But then, in my code, when the async method completes the respond function is undefined:

[Jun  4 22:30:10.727] MJS callback error: [respond] is not defined

I encountered similar issue when implementing the async handler.
And managed to work around it by declaring the function directly inside RPC._ahcba.
It seems that the garbage collector is fairly aggressive and discards the respond variable.

Do you have na idea why this happens? And whether it is possible to solve it?