Update background.ts

This commit is contained in:
Tommy D. Rossi
2026-01-23 17:39:24 +01:00
parent 608afc8d54
commit 09f502cc43
+7 -1
View File
@@ -1122,7 +1122,13 @@ async function handleStartRecording(params: StartRecordingParams): Promise<{ suc
const streamId = await new Promise<string>((resolve, reject) => {
chrome.tabCapture.getMediaStreamId({ targetTabId: tabId }, (id) => {
if (chrome.runtime.lastError) {
reject(new Error(chrome.runtime.lastError.message))
const errorMsg = chrome.runtime.lastError.message || 'Unknown error'
// Chrome returns this error when activeTab permission hasn't been granted
if (errorMsg.includes('Extension has not been invoked') || errorMsg.includes('activeTab')) {
reject(new Error(`${errorMsg}. Toggle the Playwriter extension icon on this tab to enable recording, then try again.`))
} else {
reject(new Error(errorMsg))
}
} else if (!id) {
reject(new Error('Failed to get media stream ID'))
} else {