diff --git a/apps/browser/src/autofill/utils/index.ts b/apps/browser/src/autofill/utils/index.ts index bc486820642..95e84d19d12 100644 --- a/apps/browser/src/autofill/utils/index.ts +++ b/apps/browser/src/autofill/utils/index.ts @@ -105,7 +105,19 @@ export async function sendExtensionMessage( command: string, options: Record = {}, ): Promise { - return chrome.runtime.sendMessage({ command, ...options }); + if (typeof browser !== "undefined") { + return browser.runtime.sendMessage({ command, ...options }); + } + + return new Promise((resolve) => + chrome.runtime.sendMessage(Object.assign({ command }, options), (response) => { + if (chrome.runtime.lastError) { + resolve(null); + } + + resolve(response); + }), + ); } /**