5

別の拡張機能にメッセージを送信しようとすると、ID が無効になることがあります (拡張機能が削除された可能性があります) が、sendMessage はこれを通知しません。私が知る限り、次のように出力されconsole.errorます:

これは、Chrome のソース コードの miscellaneous_bindings 行 235 です。

chromeHidden.Port.dispatchOnDisconnect = function(  portId, errorMessage)
{
    var port = ports[portId];
    if (port) {
        // Update the renderer's port bookkeeping, without notifying the browser.
        CloseChannel(portId, false);
        if (errorMessage) {
            lastError.set(errorMessage, chrome);
            //It prints: Port error: Could not establish connection. Receiving end does not exist.
            console.error("Port error: " + errorMessage);
        }
        try {
            port.onDisconnect.dispatch(port);
        } finally {
            port.destroy_();
            lastError.clear(chrome);
        }
    }
};

その結果、私のアプリはメッセージを送信しようと何度も試みたままになります。私が持っている唯一のヒントsendResponse()は、から返された空の応答ですが、どのアプリでも空の応答オブジェクトを送信できます! 失敗したことをどうやって知ることができますか?

4

1 に答える 1