Evaluating the DuckDB JavaScript interface in a Code Node

Describe the problem/error/question

I have installed duckdb as an npm package (npm install -g duckdb)
added $env:NODE_FUNCTION_ALLOW_EXTERNAL = “*” and I’m trying to use a JavaScript in a code node. The code should create a table, populate it and run a SELECT against the table. The code returns empty result and I don’t know how to debug.

The duckdb javascript interface is described here : Node.js API – DuckDB

What is the error message (if any)?

No error, … result is empty

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.55.3
  • Database (default: SQLite): SQLLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Windows 11

Adding a sleep make it works (but it is not how it should be done :))

As duckdb functions are async function based on callbacks, the proper way would be to wrap all the function call in proper Promise/Resolve javascript.

Is your current implementation, the code node finishes before the callback is even triggered

2 Likes

Correct !
and it seems that the promise/resolve layer is available : duckdb-async - npm

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.