Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

File System Provider Extension Events, Mount Lifecycle, and Abort

How Chrome extension fileSystemProvider events mount virtual file systems, stream reads and writes, and handle abort, configure, and unmount.

This page summarises Google Chrome extension documentation for the file system provider pattern: an extension exposes a virtual file system that ChromeOS (and related UI) treats like a mounted volume. The current surface is browser.fileSystemProvider in the extensions reference; the same event contracts appear under chrome.fileSystemProvider in the Manifest V2 reference. You implement the API by registering listeners for request events and completing each request through the matching success or error callback (and sometimes a follow-up API call such as unmount).

A file system provider extension is appropriate when users need network or custom backends inside the system Files experience—for example corporate storage, sync roots, or device-backed trees—not when a normal extension only needs occasional file picks (that path uses other APIs such as chrome.fileSystem in legacy packaged apps).

fileSystemProvider: what the browser asks your extension to do

Section titled “fileSystemProvider: what the browser asks your extension to do”

fileSystemProvider is an event-driven bridge: the browser raises an event when the user or shell needs an operation on a mounted fileSystemId, and your extension performs that operation against your backend. Operations cover the full vnode lifecycle—mount and unmount, metadata, directory listing, open/read/write/close, create/copy/move/delete, truncate, directory watchers, custom actions, optional configuration UI, and abort of in-flight work.

Most handlers share the same callback shape: (options, successCallback, errorCallback) => void, with failures reported through errorCallback using a ProviderError. Listing and reading are special because you may call successCallback multiple times with a hasMore flag until all data is delivered.

onMountRequested: how to mount a new virtual file system

Section titled “onMountRequested: how to mount a new virtual file system”

onMountRequested runs when the user should see a dialog to mount a new file system. If your extension is a file handler, you should not handle this event; mount when a file is opened via app.runtime.onLaunched instead (see chrome.app.runtime).

Raised when showing a dialog for mounting a new file system is requested. If the extension/app is a file handler, then this event shouldn’t be handled. Instead app.runtime.onLaunched should be handled in order to mount new file systems when a file is opened. For multiple mounts, the file_system_provider.multiple_mounts manifest option must be set to true.

— Google Chrome, browser.fileSystemProvider

For a dedicated provider (not opened only as a file handler), show your connection UI in the listener, then complete mounting through the provider APIs. If you support more than one simultaneous mount, set file_system_provider.multiple_mounts to true in the manifest; otherwise assume a single active mount unless your product design says otherwise.

onConfigureRequested: credentials and settings after mount

Section titled “onConfigureRequested: credentials and settings after mount”

onConfigureRequested is raised when the user opens configuration for an already mounted fileSystemId. It is optional but valuable for network-backed trees where credentials or endpoints change after mount.

Provided file systems once mounted can be configured via the onConfigureRequested event. It’s especially useful for file systems which provide contents via network in order to set proper credentials. Handling this event is optional.

— Google Chrome, browser.fileSystemProvider

If you implement the dialog, you must set file_system_provider.configurable to true in the manifest. On success, call successCallback; on failure, call errorCallback with an appropriate ProviderError.

Directory and file operations: metadata, listing, and EXISTS errors

Section titled “Directory and file operations: metadata, listing, and EXISTS errors”

onGetMetadataRequested and onReadDirectoryRequested

Section titled “onGetMetadataRequested and onReadDirectoryRequested”

onGetMetadataRequested must return EntryMetadata for entryPath through successCallback, or errorCallback on failure.

onReadDirectoryRequested must return directory children in chunks: call successCallback(entries, hasMore) repeatedly until hasMore is false. This pattern lets large folders stream without blocking the browser UI.

Section titled “onCreateDirectoryRequested, onCreateFileRequested, and related mutations”

Creation and deletion events encode POSIX-like rules:

Event Required behaviour (from documentation)
onCreateDirectoryRequested Fail with EXISTS if the directory already exists; if recursive is true, create missing parents on the path.
onCreateFileRequested Call errorCallback with EXISTS if the file already exists.
onDeleteEntryRequested If recursive is true and the entry is a directory, delete all nested entries.
onCopyEntryRequested / onMoveEntryRequested Copy or move recursively when the source is a directory; use errorCallback on any error.

onOpenFileRequested opens filePath; the operation must fail if the file does not exist. The maximum number of concurrently open files can be capped via MountOptions when you mount.

onCloseFileRequested, onTruncateRequested, and entry delete/copy/move events follow the same success/error callback discipline.

onReadFileRequested and onWriteFileRequested: chunked I/O on open handles

Section titled “onReadFileRequested and onWriteFileRequested: chunked I/O on open handles”

Reads and writes apply to a file already opened with a specific openRequestId, not to ad-hoc paths.

Raised when reading contents of a file opened previously with openRequestId is requested. The results must be returned in chunks by calling successCallback several times. In case of an error, errorCallback must be called.

— Google Chrome, browser.fileSystemProvider

For reads, each successCallback invocation passes (data: ArrayBuffer, hasMore: boolean). For directory reads, the parallel is (entries: EntryMetadata[], hasMore: boolean). Writes use onWriteFileRequested on the same openRequestId; complete with successCallback or errorCallback when the write finishes.

Design backends so chunk sizes are stable under abort: an in-flight read should respect onAbortRequested for the matching operationRequestId.

onAbortRequested: stop operations and avoid stale callbacks

Section titled “onAbortRequested: stop operations and avoid stale callbacks”

onAbortRequested is raised when the platform wants to cancel work identified by operationRequestId. Correct abort handling is strict:

Raised when aborting an operation with operationRequestId is requested. The operation executed with operationRequestId must be immediately stopped and successCallback of this abort request executed. If aborting fails, then errorCallback must be called. Note, that callbacks of the aborted operation must not be called, as they will be ignored. Despite calling errorCallback, the request may be forcibly aborted.

— Google Chrome, browser.fileSystemProvider

Stop the backend task for that operationRequestId, then call the abort request’s successCallback. Do not invoke the original operation’s callbacks afterward—they are ignored and may confuse your state machine. Even if you call errorCallback on the abort request, the browser may still force-abort the operation.

Watchers, custom actions, and onUnmountRequested

Section titled “Watchers, custom actions, and onUnmountRequested”

onAddWatcherRequested and onRemoveWatcherRequested (Chrome 45+) manage directory change notification. Failures must go to errorCallback.

onGetActionsRequested returns actions applicable to every selected entryPaths entry; return an empty array if none apply. onExecuteActionRequested runs a chosen action on a file or directory set; call successCallback when finished or errorCallback on error.

onUnmountRequested must call the unmount API method together with successCallback. If unmount is impossible (for example a pending operation), use errorCallback; document pending-work policies in your extension so users are not stuck with a busy volume.

ChromeOS fileBrowserHandler and browser.* vs chrome.*

Section titled “ChromeOS fileBrowserHandler and browser.* vs chrome.*”

When the user runs an action from the ChromeOS Files app that targets your integration, fileBrowserHandler may fire:

Fired when file system action is executed from ChromeOS file browser.

— Google Chrome, browser.fileBrowserHandler

Wire this only if your product exposes handler actions distinct from core provider events. New extension code should prefer browser.fileSystemProvider listeners from the current API reference; legacy MV2 samples use chrome.fileSystemProvider with the same event names and rules in the MV2 reference.

Other browser.* provider namespaces in this documentation family (certificate, printer, WebAuthn proxy) solve different jobs—client certificates, printing, and WebAuthn proxying—and are documented separately under certificateProvider, printerProvider, and webAuthenticationProxy. They follow the same “listen and complete the request” model but are not substitutes for mounting file systems.

  • Handling onMountRequested in a file handler app instead of mounting from onLaunched.
  • Forgetting file_system_provider.multiple_mounts when exposing more than one volume.
  • Enabling onConfigureRequested UI without file_system_provider.configurable: true.
  • Returning directory or file data in a single huge callback instead of hasMore chunks.
  • Calling original operation callbacks after onAbortRequested for the same operationRequestId.
  • Omitting unmount on onUnmountRequested success path.
  1. Confirm your manifest declares file_system_provider permissions and, if needed, multiple_mounts and configurable, against the event handlers you implement in the browser.fileSystemProvider reference.

  2. Load the unpacked extension on a ChromeOS device or appropriate test image, trigger Mount from Files, and verify onMountRequested (or file-open launch for file handlers per chrome.app.runtime) completes without errorCallback.

  3. Exercise list, open, chunked read, write, and close on a test tree; confirm large directories use multiple successCallback calls with hasMore as described in browser.fileSystemProvider.

  4. Start a long read or list, cancel from the UI, and confirm onAbortRequested stops work and does not fire callbacks for the aborted operationRequestId.

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

If something on this page does not match the official Chrome behaviour or docs, email yimasynthetic@gmail.com with the page URL and the exact statement you believe is wrong or unclear.