Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Extension API Promise Returns, Manifest V3, and Callback Fallback

When Chrome extension APIs return Promises, why Manifest V3 matters, and how callbacks, errors, and special APIs behave.

This page summarises Chrome Extensions reference material on asynchronous Promise returns: which APIs resolve with a value, when callbacks remain required, and how browser.* and chrome.* namespaces differ. The same note appears across dozens of APIs—from chrome.tabs and chrome.storage to enterprise, DevTools, and system APIs.

If you are porting an extension from Manifest V2 (MV2) or mixing await with legacy patterns, the repeated documentation line is the anchor rule; individual APIs then add return types, Chrome version gates, and exceptions (MIME handlers, WebAuthn proxy, affiliated enterprise users).

Promise returns: what changes in Manifest V3

Section titled “Promise returns: what changes in Manifest V3”

In Manifest V3 and later, many extension methods that historically used an optional callback now also return a Promise that resolves with the same payload the callback would receive. The reference pages state this uniformly for MV3-targeted extensions.

Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

— Google, chrome.tabs

The resolved type is documented per method—for example Promise<Tab>, Promise<Cookie[]>, or Promise<object> for storage reads. Common conclusion: treat Promise-based calls as the primary style in MV3 service workers and extension pages; keep callbacks only where the platform or manifest version still requires them.

Callbacks remain the documented path when the manifest is not MV3 or when the runtime is not Chrome with Promise support for that API. The cluster does not describe non-Chrome behavior in detail beyond “other platforms need to use callbacks.” Practically:

  • manifest_version: 2 — assume callback-style APIs unless you verify Promise support for a specific method and Chrome version.
  • MV3 — prefer async/await or .then() on the return value; omit the callback parameter when the Promise path is supported.

Chrome version notes on each method (for example “Chrome 88+”, “Chrome 96+”) gate when the Promise return exists; older Chrome builds may not match current reference behavior.

Newer unified reference entries use the browser.* prefix and note compatibility with the WebExtensions browser API shape, while MV2 paths remain under chrome.*.

Enterprise device attributes illustrate both shapes with the same semantics—for example browser.enterprise.deviceAttributes and chrome.enterprise.deviceAttributes. The browser.* entries note browser.* since Chrome 148. Method signatures may list an optional callback and a Promise return on the chrome.* MV2 pages:

chrome.enterprise.deviceAttributes.getDeviceAnnotatedLocation(callback?: function): Promise<string>

— Google, chrome.enterprise.deviceAttributes

Pick one namespace consistently with your build target; do not assume every chrome.* page has a matching browser.* page unless the reference lists both.

Errors: runtime.lastError instead of extension.lastError

Section titled “Errors: runtime.lastError instead of extension.lastError”

Failed asynchronous extension APIs surface errors through chrome.runtime.lastError (or the browser equivalent), not the deprecated MV2 chrome.extension.lastError:

Please use runtime.lastError.

— Google, chrome.extension

With Promises, failures often reject the Promise (for example chrome.certificateProvider PIN dialogs). With callbacks, check chrome.runtime.lastError in the callback when the result is missing or invalid. Mixing both styles in one call is a common mistake.

Return types and APIs worth special handling

Section titled “Return types and APIs worth special handling”

Most cluster entries only document Promise<SomeType> without extra rules. The following APIs add conditions that affect design and compliance.

chrome.identity / browser.identity getAuthToken resolves to GetAuthTokenResult, not only a string token:

Returns a Promise which resolves with an OAuth2 access token as specified by the manifest, or rejects if there was an error. The grantedScopes parameter is populated since Chrome 87. When available, this parameter contains the list of granted scopes corresponding with the returned token.

— Google, browser.identity

Use grantedScopes when you must confirm which scopes the browser actually granted, not just what the manifest requested.

For custom document viewers, chrome.mimeHandler / the handler page flow restricts how you read content:

The streamUrl can be fetched exactly once, and only from your extension’s origin. Read the response fully before processing it; a second fetch of the same streamUrl fails. Use originalUrl when displaying the document’s location or title, not to fetch the content, because the original request may not be repeatable.

— Google, chrome.mimeHandler (handler page behavior, as quoted in cluster)

Note: getStreamInfo() only succeeds on a handler page that Chrome loaded for a document. Calling it from another extension context, like the service worker or an options page, fails because there is no associated stream.

— Google, chrome.mimeHandler

Call getStreamInfo() only on the handler page Chrome loaded for the MIME type; fetch streamUrl once from the extension origin.

Web Authentication proxy (attach / detach)

Section titled “Web Authentication proxy (attach / detach)”

Remote desktop extensions can suspend normal WebAuthn handling via browser.webAuthenticationProxy:

Makes this extension the active Web Authentication API request proxy. … Once this method returns without error, regular processing of WebAuthn requests is suspended, and events from this extension API are raised. This method fails with an error if a different extension is already attached.

— Google, browser.webAuthenticationProxy

The attached extension must call detach() once the remote desktop session has ended in order to resume regular WebAuthn request processing. Extensions automatically become detached if they are unloaded.

— Google, browser.webAuthenticationProxy

Only one extension may be attached; always detach() when the session ends so user passkey flows recover.

Enterprise device attributes and affiliation

Section titled “Enterprise device attributes and affiliation”

Methods such as getDeviceSerialNumber() return Promise<string> but empty string when the user is not affiliated or the admin has not set the value:

Fetches the device’s serial number. Please note the purpose of this API is to administrate the device (e.g. generating Certificate Sign Requests for device-wide certificates). This API may not be used for tracking devices without the consent of the device’s administrator. If the current user is not affiliated, returns an empty string.

— Google, browser.enterprise.deviceAttributes

The same affiliation and empty-string rules apply to getDeviceAnnotatedLocation(), getDeviceAssetId(), getDeviceHostname(), and getDirectoryDeviceId() per chrome.enterprise.deviceAttributes. Do not treat an empty string as a hard error without checking enterprise policy and user affiliation.

DevTools extension APIs such as chrome.devtools.network document getContent returning Promise<object> (response body and encoding, with base64 called out for encoded content) and HAR log retrieval as Promise<object>—useful when building panel extensions that inspect network bodies without blocking the DevTools UI thread.

chrome.tabCapture notes that a successful capture can yield a streamId string for getUserMedia(), but that id is single-use and expires after a few seconds if unused—plan consumption immediately after the Promise resolves.

Situation Recommended approach
New MV3 extension const tab = await chrome.tabs.get(tabId); per method return type on the reference page
MV2 extension Callbacks unless you confirm MV3+Promise for your minimum Chrome version
Optional callback still in signature Pass no callback when using the Promise; avoid passing both
Failure handling try/catch on await, or .catch(); verify runtime.lastError when docs show callback-era patterns
Storage reads StorageArea.get resolves with a key-value object or rejects on failure

Representative Promise return lines across the cluster include chrome.alarms (Promise<Alarm[]>), chrome.declarativeNetRequest (rule match testing), chrome.downloads, and chrome.runtime (Promise<PlatformInfo>, context queries). Always copy the exact generic type from the method you call.

  • Calling Promise-based APIs from an MV2 manifest and assuming await always works.
  • Ignoring empty string results on enterprise device attribute APIs instead of checking affiliation and policy.
  • Fetching a MIME streamUrl twice or calling getStreamInfo() from a service worker.
  • Leaving webAuthenticationProxy.attach() active after a remote session ends.
  • Using chrome.extension.lastError in new code instead of chrome.runtime.lastError.
  • Treating chrome.identity getAuthToken as returning only a string and ignoring grantedScopes.
  1. Set "manifest_version": 3 in your extension manifest and load the unpacked extension in Chrome. Confirm the version on chrome.runtime platform info if needed.

  2. Pick one API you use (for example chrome.tabs or StorageArea) and call the method without a callback; confirm the return value is a Promise and matches the documented resolve type.

  3. Deliberately trigger a failing call (invalid tab id, missing permission) and confirm rejection or chrome.runtime.lastError behavior matches the method’s reference page.

  4. Cross-check the method on Chrome Extensions API reference for the exact Chrome X+ gate and whether the page states MV3-only Promise support.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match the official reference or your observed Chrome behavior, send the page URL and the exact statement to yimasynthetic@gmail.com so it can be corrected or clarified.