@gscdump/engine-duckdb-wasm 0.28.3 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -257,6 +257,16 @@ interface BootDuckDBWasmOptions {
257
257
  * server that cannot answer bounded reads fails closed.
258
258
  */
259
259
  config?: DuckDBConfig;
260
+ /**
261
+ * Cap DuckDB's memory with `SET memory_limit=<value>` right after open (e.g.
262
+ * `'2GB'`, `'512MB'`). A runaway query then errors with a clean
263
+ * out-of-memory rather than growing the WASM heap until the tab crashes —
264
+ * DuckDB has no statement-level timeout, so abandoned queries are otherwise
265
+ * only stopped by the caller's `AbortSignal` (which the runtime forwards to
266
+ * `conn.cancelSent()`). Opt-in: omit to keep DuckDB-WASM's default sizing.
267
+ * Accepts `<number>` with an optional `B`/`KB`/`MB`/`GB`/`TB` suffix.
268
+ */
269
+ memoryLimit?: string;
260
270
  }
261
271
  interface BrowserParquetFile {
262
272
  bytes: Uint8Array;
package/dist/index.mjs CHANGED
@@ -1049,6 +1049,11 @@ async function dropAttachedResources(db, conn, schema, tables, files) {
1049
1049
  for (const table of tables) await conn.query(`DROP VIEW IF EXISTS ${schema}.${table}`);
1050
1050
  if (files.length > 0) await db.dropFiles([...files]);
1051
1051
  }
1052
+ function parseMemoryLimit(value) {
1053
+ const trimmed = value.trim();
1054
+ if (!/^\d+(?:\.\d+)?\s*(?:B|KB|MB|GB|TB)?$/i.test(trimmed)) throw new Error(`invalid memoryLimit '${value}' — expected e.g. '512MB' or '2GB'`);
1055
+ return trimmed;
1056
+ }
1052
1057
  async function bootDuckDBWasm(options = {}) {
1053
1058
  const { getJsDelivrBundles, selectBundle, AsyncDuckDB, ConsoleLogger, LogLevel } = await import("@duckdb/duckdb-wasm");
1054
1059
  const bundle = await selectBundle(options.bundles ?? getJsDelivrBundles());
@@ -1058,9 +1063,11 @@ async function bootDuckDBWasm(options = {}) {
1058
1063
  try {
1059
1064
  await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
1060
1065
  await db.open(rangeOnlyConfig(options.config));
1066
+ const conn = await db.connect();
1067
+ if (options.memoryLimit !== void 0) await conn.query(`SET memory_limit='${parseMemoryLimit(options.memoryLimit)}'`);
1061
1068
  return {
1062
1069
  db,
1063
- conn: await db.connect()
1070
+ conn
1064
1071
  };
1065
1072
  } catch (err) {
1066
1073
  worker.terminate();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/engine-duckdb-wasm",
3
3
  "type": "module",
4
- "version": "0.28.3",
4
+ "version": "0.29.0",
5
5
  "description": "DuckDB-WASM engine adapter for @gscdump/analysis — typed browser analytics against parquet via R2.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -45,9 +45,9 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "drizzle-orm": "1.0.0-rc.3",
48
- "@gscdump/contracts": "0.28.3",
49
- "@gscdump/engine": "0.28.3",
50
- "gscdump": "0.28.3"
48
+ "@gscdump/contracts": "0.29.0",
49
+ "@gscdump/engine": "0.29.0",
50
+ "gscdump": "0.29.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@duckdb/duckdb-wasm": "^1.32.0",