This value is set when an asynchronous function has an error condition that it needs to report to its caller.
If you call an asynchronous function that may set lastError, you are expected to check for the error when you handle the result of the function. If lastError has been set and you don't check it within the callback function, then an error will be raised.


var myError = chrome.runtime.lastError;  // null or Error object

This API is also available as browser.runtime.lastError.


An Error object representing the error. The message property is a string with a human-readable description of the error . If lastError has not been set, the value is null.


There are two different ways add-ons can call asynchronous functions:

  • By passing in a callback to the function, which is called with the function's result.
  • By omitting the callback and using the browser namespace, in which case the function will return a Promise.

In the first case, if the function can set lastError you should check it in the callback. For example:

function logCookie(c) {
  if (chrome.runtime.lastError) {
  } else {

  {url: ""},

In the second case, lastError will be passed into the second argument of Promise.then():

function logCookie(c) {

function logError(e) {

var setCookie = browser.cookies.set(
  {url: ""}

setCookie.then(logCookie, logError);

Note: runtime.lastError is an alias for extension.lastError: they are set together, and checking either one will work.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 47.0 48.0 33

Compatibility notes


  • lastError is not an Error object. Instead, it is a plain Object with the error text as the string value of the 'message' property.


  • lastError is not an Error object. Instead, it is a plain Object with the error text as the string value of the 'message' property.

Example add-ons


This API is based on Chromium's chrome.runtime API. This documentation is derived from runtime.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: wbamberg, Makyen, urkle, chrisdavidmills
 Last updated by: wbamberg,