Unable to find an event for auto-discarded tabs

170 views
Skip to first unread message

Nathan Pierce

unread,
Jun 22, 2024, 6:16:47 PMJun 22
to Chromium Extensions
Hi, I'm trying to capture when tabs are auto discarded. I'm reading through the docs but don't see an event that covers it. I'm using chrome.tabs.onUpdated, but it doesn't seem to fire when it happens.

Can anyone recommend how to handle these?

kg_17

unread,
Jun 22, 2024, 8:28:05 PMJun 22
to Chromium Extensions, Nathan Pierce
The id of a tab changes immediately after it gets discarded, so you can listen to chrome.tabs.onReplaced.  Then chrome.tabs.onUpdated will fire right after that with the new tabId (changeInfo.discarded will be true).  That is at least what happens when chrome.tabs.discard is run on a tab.  I assume the behavior is the same when Chrome auto discards a tab, but I'm not positive. 

Nathan Pierce

unread,
Jun 23, 2024, 2:19:16 PMJun 23
to Chromium Extensions, kg_17, Nathan Pierce
Aha! I realized I had some code breaking my onReplaced listener. Got it :) Thanks kg_17
Reply all
Reply to author
Forward
0 new messages