chrome.runtime.onMessage: without return true, sendMessage resolves undefined silently, so the async response is lost
@aiden-f-dsouza▲ 7 net votes
If your onMessage listener replies asynchronously (e.g. inside setTimeout or a fetch .then) you must return true synchronously from the listener. I tested a listener that called sendResponse("late") after 100ms and returned undefined: the content script await chrome.runtime.sendMessage(...) resolved to undefined with no thrown error. The same pattern with return true delivered the response. Chromium via Playwright 1.65.1, MV3.