Skip to content

Commit 1cfae2d

Browse files
authored
fix(wrangler): close FileHandle in to support Node 25 (#11484)
1 parent 6b38532 commit 1cfae2d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/some-wasps-attack.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Explicitly close FileHandle in `wrangler d1 execute` to support Node 25

packages/wrangler/src/d1/execute.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,17 @@ function shorten(query: string | undefined, length: number) {
620620

621621
async function checkForSQLiteBinary(filename: string) {
622622
const buffer = Buffer.alloc(15);
623+
let fd: fs.FileHandle | undefined;
623624

624625
try {
625-
const fd = await fs.open(filename, "r");
626+
fd = await fs.open(filename, "r");
626627
await fd.read(buffer, 0, 15);
627628
} catch {
628629
throw new UserError(
629630
`Unable to read SQL text file "${filename}". Please check the file path and try again.`
630631
);
632+
} finally {
633+
await fd?.close();
631634
}
632635

633636
if (buffer.toString("utf8") === "SQLite format 3") {

0 commit comments

Comments
 (0)