Safari Web Extension - runtime.sendNativeMessage() failed with error 4099

Hey, I am developing Safari Web Extension and trying to communicate with the swift handler (SafariWebExtensionHandler) using runtime.sendNativeMessage api (as describe here - https://developer.apple.com/documentation/safariservices/safari_web_extensions/messaging_between_the_app_and_javascript_in_a_safari_web_extension). I'm getting the following error when calling it - calling runtime.sendNativeMessage(): Error Domain=NSCocoaErrorDomain Code=4099 "Couldn’t communicate with a helper application."

I have no Idea what is missing and couldn't find any meaningful error message anywhere. I do have nativeMessaging permission in my manifest.json. Assist will be appreciated.

Safari Web Extension - runtime.sendNativeMessage() failed with error 4099
 
 
Q