Skip to content

fix(services/opfs): support OPFS in web workers - #8319

Open
jccampagne wants to merge 3 commits into
apache:mainfrom
jccampagne:fix-opfs-worker-global-scope
Open

jccampagne wants to merge 3 commits into
apache:mainfrom
jccampagne:fix-opfs-worker-global-scope

Conversation

@jccampagne

@jccampagne jccampagne commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Also updated the call to Operator::from_config (no more .finish).

Which issue does this PR close?

Closes #8318

Rationale for this change

OPFS should be usable from web workers too.

What changes are included in this PR?

Are there any user-facing changes?

Fix issue: #8318

The OPFS service resolved the storage manager through web_sys::window().unwrap(), which panics in a web worker because there is no window there, even though navigator.storage.getDirectory() is available on WorkerNavigator.

Change to resolve navigator from the current global scope instead:

  • Window on the main thread
  • WorkerGlobalScope in workers.
  • any other global scope returns ErrorKind::Unsupported instead of panicking.

The OPFS edge tests gain a worker feature that runs the same suite in a dedicated worker, and no longer call the removed .finish() from Operator::from_config

Breaking changes

AI Usage Statement

Yes, used ClaudeCode to check.

The OPFS service resolved the storage manager through
`web_sys::window().unwrap()`, which panics in a web worker because
there is no `window` there, even though
`navigator.storage.getDirectory()` is available on `WorkerNavigator`.

Resolve `navigator` from the current global scope instead: `Window` on
the main thread, `WorkerGlobalScope` in workers. Any other global
scope returns `ErrorKind::Unsupported` instead of panicking.

The OPFS edge tests gain a `worker` feature that runs the same suite
in a dedicated worker, and no longer call the removed `.finish()`
after `Operator::from_config`.fix(services/opfs): support OPFS in web
workers

The OPFS service resolved the storage manager through
`web_sys::window().unwrap()`, which panics in a web worker because
there is no `window` there, even though
`navigator.storage.getDirectory()` is available on `WorkerNavigator`.

Resolve `navigator` from the current global scope instead: `Window` on
the main thread, `WorkerGlobalScope` in workers. Any other global
scope returns `ErrorKind::Unsupported` instead of panicking.

The OPFS edge tests gain a `worker` feature that runs the same suite
in a dedicated worker, and no longer call the removed `.finish()`
after `Operator::from_config`.
@jccampagne
jccampagne requested a review from Xuanwo as a code owner September 17, 2026 14:40
@github-actions github-actions Bot added releases-note/fix The PR fixes a bug or has a title that begins with "fix" services/opfs OpenDAL opfs service. size:M This PR changes 30-99 lines, ignoring generated files. labels Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/fix The PR fixes a bug or has a title that begins with "fix" services/opfs OpenDAL opfs service. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: OPFS service panics in a web worker

1 participant