sendResponse is not waiting for fetch to complete.
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
async function f() {
const e = await fetch('a.txt')
return await e.text()
}
f().then(r => {
sendResponse({res: r})
})
})
On the content.js page the following error is shown:
Uncaught (in promise) Error: The message port closed before a response was received.
Where is the error?