Skip to content

Commit

Permalink
fix: error message when channel is closed (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie authored Jul 29, 2024
1 parent 93a9c60 commit ee5cd1e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/devtool-chrome/src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ chrome.runtime.onConnect.addListener(function (port) {

// Receive message from content script and relay to the devTools page for the
// current tab
chrome.runtime.onMessage.addListener((request: Message, sender: chrome.runtime.MessageSender) => {
chrome.runtime.onMessage.addListener((request: Message, sender: chrome.runtime.MessageSender, sendResponse) => {
const converted = convertPostMessageData(request);
if (converted.method === DevtoolMessage.active) {
setIconAndPopup(DevtoolMessage.active, sender.tab?.id ?? 0);
Expand All @@ -73,11 +73,15 @@ chrome.runtime.onMessage.addListener((request: Message, sender: chrome.runtime.M
tabId: sender.tab?.id,
...message,
});
// Send a response back to the sender
sendResponse({ status: 'success' });
} else {
console.log('Tab not found in connection list.');
sendResponse({ status: 'error', message: 'Tab not found in connection list.' });
}
} else {
console.log('sender.tab not defined.');
sendResponse({ status: 'error', message: 'sender.tab not defined.' });
}
return true;
});
Expand Down

0 comments on commit ee5cd1e

Please sign in to comment.