Bug: URL mode panics with `condvar wait not supported` on multi-partition scans
Describe the bug
I have been trying to figure out a workaround for this to no avail. Please let me know if one exists?
#2291 fixed tokio::task::spawn panics by wrapping queries in a single-threaded runtime.
But URL mode (ListingTable over HTTP) still crashes on multi-partition file scans because
FileScanExec internally uses std::sync::Condvar for parallel scan coordination, and the
no-threads WASM target panics on condvar usage.
Inline mode works fine against the same file because the in-memory Parquet reader doesn't
create multi-partition plans.
To Reproduce
<script type="module">
import { WrenEngine } from "@wrenai/wren-core-wasm";
const engine = await WrenEngine.init();
const mdl = {
catalog: "wren", schema: "public",
models: [{ name: "T", tableReference: { table: "t" },
columns: [{ name: "id", type: "INTEGER" }], primaryKey: "id" }],
relationships: [], views: [],
};
// Any Parquet with enough rows/columns to trigger >1 scan partition
await engine.loadMDL(mdl, { source: "https://example.com/data/" });
await engine.query('SELECT count(*) FROM "T"'); // panics
</script> Crash:
panicked at rustc/.../condvar/no_threads.rs:20:9:
condvar wait not supported Root cause
ListingTable creates multi-partition scan plans. FileScanExec spawns tasks per partition
and uses std::sync::Condvar for coordination. On wasm32-unknown-unknown (no
atomics/threading), Condvar::wait is a compile-time panic.
Suggested fix
Configure the SessionContext with target_partitions = 1 for WASM builds. This forces
single-partition scans, avoids the multi-task spawn path in FileScanExec, and keeps
queries on the existing single-threaded runtime (#2291). For WASM use cases, parallelism is
unavailable anyway, so a single partition is both safe and correct.
Environment
@wrenai/wren-core-wasmv0.4.1 (post-#2291 fix)- Chrome 150
- 108-column, ~4M-row Parquet on Cloudflare R2
Source: Canner/WrenAI