File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,7 +141,25 @@ def sync(
141141 if IS_WASM : # pragma: no cover
142142 # This code path is covered in the Pyodide/WASM CI job.
143143 current_loop = asyncio .get_running_loop ()
144- return current_loop .run_until_complete (coro )
144+ result = current_loop .run_until_complete (coro )
145+ # Check if run_until_complete actually executed the coroutine or just returned a task
146+ # In browsers without JSPI, run_until_complete is a no-op that will return the task/future.
147+ if isinstance (result , (asyncio .Task , asyncio .Future )):
148+ raise RuntimeError (
149+ "Cannot use synchronous zarr API in browser environments without JSPI. "
150+ "Zarr requires JavaScript Promise Integration (JSPI) to work in browsers "
151+ "but JSPI is not enabled in your environment.\n "
152+ "Solutions:\n "
153+ "1. Use the async API instead, with zarr.api.asynchronous"
154+ "2. Enable JSPI in your Pyodide setup with "
155+ "`loadPyodide({ enableRunUntilComplete: true })`"
156+ "3. Use a JSPI-enabled website or browser configuration"
157+ "4. If you are using Node.js, pass the --experimental-wasm-jspi flag (v20+)"
158+ "\n "
159+ "Note: JSPI is experimental and not yet standardised across all browsers. See "
160+ "https://webassembly.org/features/ for more information and status."
161+ )
162+ return result
145163
146164 # This code path is the original thread-based implementation
147165 # for non-WASM environments; it creates a dedicated I/O thread
You can’t perform that action at this time.
0 commit comments