Open nshiab opened 1 month ago
This is because we currently don't support "lifecycle hooks" when installing npm dependencies (eg. postinstall
script). We have a PR that implements that that's WIP: https://github.com/denoland/deno/pull/23558.
You can work around this for now if you use "bring your own node modules" - by installing using npm/yarn/pnpm
.
Thank you!
Hi @nshiab , have you succeeded?
I tried but I got this error:
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: macos aarch64
Version: 1.40.4
Args: ["deno", "run", "--allow-all", "data/index.ts"]
thread 'main' panicked at cli/napi/js_native_api.rs:2508:56:
called `Result::unwrap()` on an `Err` value: BadType { actual: "v8::data::Value", expected: "v8::data::Array" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
My data/index.ts contains:
import duckdb from "duckdb";
console.log(duckdb)
const db = new duckdb.Database(":memory:");
console.log(db)
The steps are:
npm init
npm install duckdb
deno run --allow-all ./data/index.ts
error: Uncaught (in promise) Error: Cannot find module 'MY_PATH/node_modules/.deno/duckdb@0.10.2/node_modules/duckdb/lib/binding/duckdb.node'
Require stack:
cd node_modules/duckdb
npm install
duckdb.node
under node_modules > duckdb > lib > binding > duckdb.nodedeno run --allow-all ./data/index.ts
============================================================ Deno has panicked. This is a bug in Deno. Please report this at https://github.com/denoland/deno/issues/new. If you can reliably reproduce this panic, include the reproduction steps and re-run with the RUST_BACKTRACE=1 env var set and include the backtrace in your report.
Platform: macos aarch64 Version: 1.40.4 Args: ["deno", "run", "--allow-all", "./data/index.ts"]
thread 'main' panicked at cli/napi/js_native_api.rs:2508:56:
called Result::unwrap()
on an Err
value: BadType { actual: "v8::data::Value", expected: "v8::data::Array" }
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
By adding `RUST_BACKTRACE=1`, I get:
============================================================ Deno has panicked. This is a bug in Deno. Please report this at https://github.com/denoland/deno/issues/new. If you can reliably reproduce this panic, include the reproduction steps and re-run with the RUST_BACKTRACE=1 env var set and include the backtrace in your report.
Platform: macos aarch64 Version: 1.40.4 Args: ["deno", "run", "--allow-all", "./data/index.ts"]
thread 'main' panicked at cli/napi/js_native_api.rs:2508:56:
called Result::unwrap()
on an Err
value: BadType { actual: "v8::data::Value", expected: "v8::data::Array" }
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: core::result::Result<T,E>::unwrap
4: _napi_set_element
5: ZNK4Napi6Object3SetIA11cEEbjRKT
6: ZN10NodeDuckDBC2EN4Napi3EnvENS0_6ObjectE
7: __ZN4Napi5AddonI10NodeDuckDBE4InitENS_3EnvENS_6ObjectE
8: _napi_register_module_v1
9: deno_napi::op_napi_openRUST_BACKTRACE=full
for a verbose backtrace.
And by adding `RUST_BACKTRACE=full`, I get:
============================================================ Deno has panicked. This is a bug in Deno. Please report this at https://github.com/denoland/deno/issues/new. If you can reliably reproduce this panic, include the reproduction steps and re-run with the RUST_BACKTRACE=1 env var set and include the backtrace in your report.
Platform: macos aarch64 Version: 1.40.4 Args: ["deno", "run", "--allow-all", "./data/index.ts"]
thread 'main' panicked at cli/napi/js_native_api.rs:2508:56:
called Result::unwrap()
on an Err
value: BadType { actual: "v8::data::Value", expected: "v8::data::Array" }
stack backtrace:
0: 0x1018f46b0 -
Have you managed to use duckdb in Deno?
What could I do?
Best
--Update--
I've upgraded to deno 1.43.1 (was 1.40.4), and now I get this error:
error: Uncaught (in promise) Error: Error in native callback
at Object.Module._extensions..node (node:module:704:20)
at Module.load (node:module:597:32)
at Function.Module._load (node:module:484:12)
at Module.require (node:module:609:19)
at require (node:module:715:16)
at Object.<anonymous> (file:MYPATH/node_modules/.deno/duckdb@0.10.2/node_modules/duckdb/lib/duckdb-binding.js:4:15)
at Object.<anonymous> (file:MYPATH/node_modules/.deno/duckdb@0.10.2/node_modules/duckdb/lib/duckdb-binding.js:7:4)
at Module._compile (node:module:659:34)
at Object.Module._extensions..js (node:module:673:10)
at Module.load (node:module:597:32)
Do you have any idea?
Hi @MaximePawlakFr!
For now, I am using node/npm. But @bartlomieju is working on it https://github.com/denoland/deno/pull/23558.
It's an internal bug in Deno, but it seems easy enough to fix it to make example from DuckDB's page work. I'll try to have it done tonight.
I merged a fix that makes DuckDB work. It should be available in canary in ~2h - you can then use deno upgrade --canary
to try it out.
Thank you Bartek.
I've just updated deno to deno 1.43.1+cbb78e1
.
I tried again. I can load duckdb without the previous error.
But I can not run any request to duckdb. I get a segmentation fault
.
Here is my code:
import duckdb from "duckdb";
const db = new duckdb.Database(":memory:");
console.log(db);
Deno.serve(async (req) => {
const request =
"SELECT * FROM 'https://shell.duckdb.org/data/tpch/0_01/parquet/orders.parquet' LIMIT 1000;";
console.log(request);
const result = await new Promise((resolve, reject) => {
db.all(request, function (err, res) {
console.log(res);
if (err) {
console.warn(err);
reject(err);
}
resolve(res);
});
});
const res = JSON.stringify(
result,
(key, value) => typeof value === "bigint" ? value.toString() : value, // return everything else unchanged
);
return new Response(
res,
{
headers: { "Content-Type": "application/json" },
},
);
});
I run deno run --allow-all index.ts
I see in my terminal:
Database {}
Listening on http://localhost:8000/
SELECT * FROM 'https://shell.duckdb.org/data/tpch/0_01/parquet/orders.parquet' LIMIT 1000;
zsh: segmentation fault deno run --allow-all index.ts
It looks like something went wrong with duckdb. Any idea what?
Regards
So far I'm not able to reproduce this segmentation fault on my end - I get results as expected. Can you update once again to latest canary and try again?
I merged a fix that makes DuckDB work. It should be available in canary in ~2h - you can then use
deno upgrade --canary
to try it out.
Unfortunately, I am on a M1 Mac, so I can't install canary versions, from what I gathered.
@nshiab you can, we've been shipping canary version for ARM Macs for a couple months now :)
@bartlomieju What am I doing wrong? 😢
Thank you so much for your help!
It appears that deno
binary you have locally on your system was installed via homebrew
. You should remove it using homebrew and then install it again using the script, then add it to you PATH.
You are right. Stupid mistake on my end. Sorry.
Unfortunately, it doesn't seem to work on my laptop. Should I do something differently?
@nshiab the problem with postinstall
scripts is not solved - you still need to use npm install
and use DENO_FUTURE=1
env var, I fixed the problem related to actual execution of DuckDB.
Hmmm. I tried again but I am still doing something wrong I guess. It's probably best if I wait for postinstall
scripts to work.
@nshiab you need to specify DENO_FUTURE
env var in your terminal when you run the deno
command:
# bash
DENO_FUTURE=1 deno run -A index.ts
# fish
env DENO_DUTURE=1 deno run -A index.ts
IT WORKS! Amazing! Thanks for your patience @bartlomieju!
But... if I actually run a query, it fails. This is an example from the duckdb repo.
Thanks! I don't get a segfault, but I'm getting a panic like so:
import duckdb from "duckdb";
const db = new duckdb.Database(":memory:");
const con = db.connect();
con.all("SELECT 42 AS fortytwo", function (err, res) {
if (err) {
console.warn(err);
}
console.log(res[0].fortytwo);
})
env DENO_FUTURE=1 deno run -A index.ts
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.
Platform: macos aarch64
Version: 1.43.1+998036b
Args: ["deno", "run", "-A", "index.ts"]
thread 'main' panicked at cli/napi/js_native_api.rs:2348:63:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I'll try to debug this one as well.
So far I'm not able to reproduce this segmentation fault on my end - I get results as expected. Can you update once again to latest canary and try again?
I've just update to the last canary: deno 1.43.1+998036b
I still get the same segmentation fault
.
Keep me in the loop if you make any advance.
Thanks a lot for what you tried.
Version: Deno 1.41.3
Hi!
I tried to use duckdb-node with Deno by running this
index.ts
.But when running
deno run -A index.ts
, I get this error:Is it possible to use DuckDB with Deno?
Thank you very much for your great work.