Still getting "Unchecked runtime.lastError" error in Console, despite placing runtime.lastError checks everywhere

425 views
Skip to first unread message

tommai78101

unread,
Mar 18, 2019, 10:08:16 AM3/18/19
to Chromium Extensions
Hello,

My problem has to do with tracking down this annoying "Unchecked runtime.lastError" error message. It appears randomly, but only on the content script. The background scripts all have the errors detected and logged correctly, so I do not think it has to do with background scripts at all. It's company code, so I can't freely share the code to anyone.

I have done the following:
  • Added if (chrome.runtime.lastError) console.error("(debug) ", chrome.runtime.lastError.message); everywhere to all functions where I do chrome.runtime.sendMessage and chrome.runtime.onMessage.addListener. Still can't successfully print out the message containing the substring, "(debug)", as this trick is how I would know the error has been found in the content scripts.
  • Disabled all other extensions on the test browser (Chrome Canary, Chrome Dev, and Chrome Stable). Still getting this extension error, hinting that it's really the extension I'm working on that's causing the error.

I'm wondering what other causes I didn't know about that is making the "Unchecked runtime.lastError" error message popping up in the Console.

If any one know, let me know.

If Chrome or Chromium has a way to halt all asynchronous function calls when an exception or a runtime.lastError has been hit, that would be really awesome. But I know, this is a tall order and it's downright impossible to do. Just wishful thinking.

wOxxOm

unread,
Mar 19, 2019, 11:02:45 AM3/19/19
to Chromium Extensions
Errors usually have a source link either at the right side of the console or inside the error stack trace within the message itself.

tommai78101

unread,
Mar 19, 2019, 1:00:08 PM3/19/19
to Chromium Extensions

They usually do, but for asynchronous errors being received like this and you have your background scripts set in the manifest to be read as a "page", not "script", they (Chrome) don't provide you where the error message is coming from. Instead, all they do is they have the source link straight to the background HTML page. And there are no stack traces included.

wOxxOm

unread,
Mar 19, 2019, 1:23:45 PM3/19/19
to Chromium Extensions
Maybe you could try a divide-and-conquer approach - comment out as much as possible (almost everything) until the bug is gone, then restore in chunks until it fails so you'll know at least where it happens.

Another possibility is adding a customized console.log call to the internal JS shim that's stored in resources.pak, specifically runCallbackWithLastError. There are several tools to unpack/repack resources.pak, I've used pak_tools.exe in Windows.

On Monday, March 18, 2019 at 5:08:16 PM UTC+3, tommai78101 wrote:

tommai78101

unread,
Mar 19, 2019, 3:49:04 PM3/19/19
to Chromium Extensions
I'm just going to try the first approach and see where it leads me to. The second approach sounds really awfully hard, and I wouldn't want to touch unless there is a written guide with pictures out there.
Reply all
Reply to author
Forward
0 new messages