Open jbsiddall opened 2 days ago
found if i deleted node_modules and pnpm install
and pnpm tsx ./foo.ts
using node v22 this bug doesn't exist.
Tried the same reinstall using node 20 and bug appears again.
So this potentially involves a node.js bug that has been resolved, you think?
@kriszyp can you run this dockerfile and tell me if you get the same error? ideally you run it on a linux amd64 architecture:
from --platform=linux/amd64 node:22-slim
WORKDIR /app
run npm install -g pnpm
run pnpm install lmdb
RUN cat <<EOF > foo.mjs
import { open } from 'lmdb'
async function main() {
const env = open('mydb', {})
env.clearSync()
for (let i = 0; i < 1_000_000; i++) {
env.put(i, i)
}
}
main()
EOF
cmd rm -rf ./mydb && node ./foo.mjs && node ./foo.mjs
docker build -t foo && docker run -it --rm foo
. I still get error that i reported at the top of this. i also checked on a hetzner server and running this docker image on that also had same error.
found that this dockerille works fine:
from --platform=linux/amd64 node:22-slim
WORKDIR /app
run npm install -g pnpm
run pnpm install lmdb
RUN cat <<EOF > foo.mjs
import { open } from 'lmdb'
async function main() {
const old = open('mydb', {})
const env = old.openDB('main')
env.clearSync()
for (let i = 0; i < 1_000_000; i++) {
env.put(i, i)
}
}
main()
EOF
cmd rm -rf ./mydb && node ./foo.mjs && node ./foo.mjs
Possible conclusion: bug with lmdb or library where 'clearing' the env fails, but clearing the database in the env works fine. Can i confirm that the lmdb env is meant to be clearable?
okay wow i'm spamming this channel but epic new insight. on node v22, this bug only exists if the env's name isn't set. eg bug:
import { open } from 'lmdb'
async function main() {
const env = open('mydb', {})
env.clearSync()
for (let i = 0; i < 1_000_000; i++) {
env.put(i, i)
}
}
no bug:
import { open } from 'lmdb'
async function main() {
const env = open('mydb', {name: 'main'})
env.clearSync()
for (let i = 0; i < 1_000_000; i++) {
env.put(i, i)
}
}
Hello!
i've a script that crashes node. filing this to either report bug or get schooling in how to use lmdb :P
I've a foo.ts script:
and when run twice back to back
rm -rf mydb && pnpm tsx ./foo.ts && pnpm tsx ./foo.ts
causes node to crash on the second run with this error:first time the foo.ts is run, it creates db, and second time it runs it seems to crash on on
env.clearSync()
.I reran
rm -rf mydb && pnpm tsx ./foo.ts && pnpm tsx ./foo.ts
many times becuase i noticed unusual race conditions. one time it would output:no errors but
echo $?
did output 139.maybe 1 in 30 times of running it i get this error:
PS i know my project in the stacktrace is called
playingcbor
but cbor has no part to play in this script or bug.attached project files for context:
code.zip
has 3 files: package.json, pnpm-lock.yaml, foo.ts, and mydb/ which has the db resulting from running
rm -rf mydb && pnpm tsx ./foo.ts && pnpm tsx ./foo.ts
.I'm running this on nixos: