TypeError 'set' on proxy: trap returned falsish for property 'ObjectMessage'
I want to send a JSON objct to the delphi side.
I'm using
Delphi 10.3.3 or 10.4 (but I would really love it to work on both)
MS Edge Version 88.0.705.50 (Official build) (64-bit)
FNC Core 3.2.2.2
Control: is TFNCWebBrowser
yes, but it's unclear how { type, payload } is supposed to be interpreted. is type and payload a string parameter? Note that valid JSON needs to have a name and value (value can also be something other than a string ofcourse):
{"Name": "Value"}
I have tested by using JSON.stringify({"Name": "Value"}); here before sending it and this is working as expected. I suggest to start with a simple method to call the bridge ObjectMessage and build up from there. If the issue persists, please send us a simple sample demonstrating the error.
Did you already start from scratch building up with a simple example sending through JSON? This might give you an insight on what exactly is different with your real application.
we always have it. the bridge is sent successfully to the delphi side and we receive all the data but our logging system is still reporting that we had an error at that point.
I suppose this is because the json is not a string but an object and therefore does not match the type of the ObjectMessage property which is also string.
I feel like I can only post in the categories of the components I bought... and I am just evaluating the TTMSFNCWebBrowser as a replacement for the VCL TWebBrowser in Edge mode (for which the deployment is a joke...).
I will investigate the problem a little more and send you my observations.
In a few words:
I am using a Vue.js environment
My call is close to yours (I don't use the TTMSFNCWebBrowser.GetBridgeCommunicationLayer, I just call window.chrome.webview.hostObjects.sync.MyBridgeName from Javascript)
I get the same Javascript error: TypeError: 'set' on proxy: trap returned falsish for property 'ObjectMessage' Here we can see that setter should return au boolean value.
I have no error by scrupulously following the documentation example (who uses the TTMSFNCWebBrowser.LoadHTML, I don't know if it matters).
Maybe it is related to using the same bridge tech on a webserver instead of plain HTML/JavaScript. We'll try and see if it is related to this difference.
Hi we have further investigated this here and it seems that the error is thrown because the setter implementation on the proxy object is not returning true. It appears to be a requirement. We will monitor closely to what Microsoft will do as this is internal Edge Chromium code. We also noticed that the sync version is the reason why this error is thrown. Removing the sync version (going to async), no longer throws the exception. Note that the property will be set, but the code that happens at the client will happen asynchronously. So to avoid the error you can use the updated code:
Note that as it is going from sync to async: any code that happens after obj.ObjectMessage = parameters; will be executed directly independent of what happens at the client. I guess that for performance and to avoid the web application from hanging it is better to switch to async anyway.