SkipLabs / skdb

SKDB is an embedded SQL database that stays in sync.

Home Page:https://skdb.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Piping input to the CLI causes readline errors

ltratt opened this issue · comments

A classic trick I use for setting up databases is piping commands into their CLI. This causes a readline issue at the moment:

echo "CREATE TABLE t3 ( x TEXT );" | npx skdb --dev --db chat_app --remote-repl
root@ws://localhost:3586/chat_app> CREATE TABLE t3 ( x TEXT );
node:internal/errors:497
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_USE_AFTER_CLOSE]: readline was closed
    at new NodeError (node:internal/errors:406:5)
    at [kQuestion] (node:internal/readline/interface:397:13)
    at node:readline/promises:57:22
    at new Promise (<anonymous>)
    at Interface.question (node:readline/promises:34:12)
    at remoteRepl (file:///home/ltratt/.npm/_npx/cc5540d868b72d43/node_modules/skdb/dist/skdb-cli.mjs:295:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///home/ltratt/.npm/_npx/cc5540d868b72d43/node_modules/skdb/dist/skdb-cli.mjs:458:5 {
  code: 'ERR_USE_AFTER_CLOSE'
}

Node.js v20.9.0

I thought that adding --simple-output might solve this, but the error is unchanged.

An alternative to fixing this might be to add a commands (or similarly named) switch which takes a file with commands as input?