ポップアップ ウィンドウからバックグラウンド プロセスにメッセージを送信します。フィードバック信号は私には必要ありません。sendResponse を呼び出せませんか。
popup.js
window.onload = function(){
chrome.extension.sendMessage('Hi, i opened');
}
background.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
console.log(request);
console.log(sendResponse);
// sendResponse not called
})
sendmessage responseCallback オプション関数developer.chrome.com/extensions/runtime.html#method-sendMessageのドキュメント
responseCallback を転送しない場合は、そこに sendResponse を送信します。上記のコードはそれを出力します。
function (response) {
if (port) {
port.postMessage(response);
port.destroy_();
port = null;
} else {
// We nulled out port when sending the response, and now the page
// is trying to send another response for the same request.
handleSendRequestError(isSendMessage, responseCallbackPreserved,
sourceExtensionId, targetExtensionId);
}
}
ポートの機能で削除されます。sendResponseを呼び出さないと確実にメモリリークになる可能性があります