nodejs / nodejs/node

node:sqlite: backup() unwraps any object as a DatabaseSync, and a duck-typed URL aborts the process

Open
#65,830 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

v27.0.0-pre (884f9cd62da)

Platform
Darwin 25.6.0 arm64
Subsystem

sqlite

What steps will reproduce the bug?

node:sqlite's backup() checks that its first argument is an object, then unwraps it. Passing anything other than a DatabaseSync results in a crash:

const { backup } = require('node:sqlite');
backup({}, '/tmp/c1a.db');

Similarly, the DatabaseSync constructor treats any object as a URL if it has a string href. If that href doesn't parse, it crashes:

const { DatabaseSync } = require('node:sqlite');
new DatabaseSync({ href: 'zzz' });
How often does it reproduce? Is there a required condition?

It's consistent.

What is the expected behavior? Why is that the expected behavior?

Both should raise a TypeError.

What do you see instead?

A segfault.

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the node:sqlite implementations of backup() and the DatabaseSync constructor, then reproduce both examples from the issue. The work is done when invalid backup arguments and malformed URL-like objects raise TypeError instead of causing a segfault, with regression coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, sqlite
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.