【发布时间】:2013-06-07 21:28:42
【问题描述】:
我的后台脚本中有以下代码。我向另一个应用程序发送一条消息,但如果它失败了,它会被调用两次(注意:我的回调被调用了两次。我的代码调用 sendMessage 只被调用一次)!
chrome.runtime.sendMessage(
otherAppId,
someObject,
function (response)
{
var lastError = chrome.runtime.lastError;
//This likely means it doesn't exist ("Could not establish connection. Receiving end does not exist.")
if ( lastError && lastError.message.indexOf( "not exist" ) !== -1 )
{
///This gets called twice!
console.log( "we're here twice?!" );
}
//This is called once
else console.log( "Was successful, so called only once" );
}
);
有没有办法取消它,让它停止重试?为什么一个错误会导致两次调用我的回调?
【问题讨论】:
-
对我来说听起来像是一个错误,请将其归档到 crbug.com。如果可能的话,包括一个完整的应用程序,以加快开发人员复制和修复它的能力。
标签: google-chrome google-chrome-extension google-chrome-devtools google-chrome-app