[FAQ] chrome.runtime.onMessage 问题, Unchecked runtime.lastError: The message port closed before a response was received
// quasar background-hook.js chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { if (request.accessToken !== '') { chrome.storage.local.set({ accessToken: request.accessToken }, () => { sendResponse({ farewell: 'success' }) }) } // Fix, Unchecked runtime.lastError: The message port closed before a response was received. return true })
Refer:chrome.runtime.onMessage