When the sidePanel is opened, any async handler in the background that is triggered by the content script via `chrome.runtime.sendMessage` is resolved synchronously and returning null. I can see that the messages are received and processed by the background, but the responses are sent back to the content script before the async callbacks resolve.
When the sidePanel is closed, everything was and is working fine.
I’m following best practices I found in the documentation and in discussions in this group, such as registering listeners at the top level
```
chrome.runtime.onMessage.addListener(onMessageHandler);
```
or returning true in callbacks:
```
const onMessageHandler = (
message: Message,
sender: chrome.runtime.MessageSender,
sendMessage: (result: any) => void
) => {
(async () => {
switch (message.action) {
case 'message': {
const response = await fetchWhatever();
sendMessage(response);
break;
}
}
})();
return true;
};
```
Has anyone faced similar issues?
Does anyone know what causes this behavior?
Am I doing something wrong?
Thanks in advance!
Oriol