Skip to content

Commit 6165bf4

Browse files
authored
🐛 fix ignore discarded tab (#1058)
* fix: ignore discarded tab * Update value.ts
1 parent 6cdbaec commit 6165bf4

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/app/service/service_worker/value.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export class ValueService {
126126
}
127127
// 推送到所有加载了本脚本的tab中
128128
for (const tab of tabs) {
129-
const tabId = tab.id!;
129+
const tabId = tab.id;
130+
if (tab.discarded || !tabId) continue;
130131
this.popup!.getScriptMenu(tabId).then((scriptMenu) => {
131132
if (scriptMenu.find((item) => item.storageName === storageName)) {
132133
this.runtime!.sendMessageToTab(

src/pkg/utils/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export function parseStorageValue(str: string): unknown {
8282
export async function getCurrentTab(): Promise<chrome.tabs.Tab | undefined> {
8383
// `tab` will either be a `tabs.Tab` instance or `undefined`.
8484
const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true, windowType: "normal" });
85+
if (tab?.discarded) return undefined;
8586
return tab;
8687
}
8788

0 commit comments

Comments
 (0)