Skip to content

sqlite-bun query prep fail in Effect, not defect#6044

Open
0xh3x wants to merge 1 commit intoEffect-TS:mainfrom
0xh3x:fix/sqlite-bun-query-prepare
Open

sqlite-bun query prep fail in Effect, not defect#6044
0xh3x wants to merge 1 commit intoEffect-TS:mainfrom
0xh3x:fix/sqlite-bun-query-prepare

Conversation

@0xh3x
Copy link
Contributor

@0xh3x 0xh3x commented Feb 8, 2026

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Fix @effect/sql-sqlite-bun so prepare errors from db.query are returned as SqlError failures (catchable with Effect.catchAll) rather than fiber defects.

Repro snippet (before this change, the program dies instead of failing with SqlError):

import { Reactivity } from "@effect/experimental"
import { FileSystem } from "@effect/platform/FileSystem"
import { SqliteClient } from "@effect/sql-sqlite-bun"
import { Effect } from "effect"

const program = Effect.gen(function*() {
  const fs = yield* FileSystem
  const dir = yield* fs.makeTempDirectoryScoped()
  const sql = yield* SqliteClient.make({ filename: dir + "/test.db" })

  // Non-existent table triggers Bun's prepare error (db.query),
  // which *used to* surface as a defect (die), not a SqlError failure.
  yield* sql`SELECT * FROM non_existent_table`
}).pipe(
  Effect.scoped,
  Effect.provide([BunFileSystem.layer, Reactivity.layer]),
  // This should catch the SqlError after the fix.
  // Before the fix, this handler never ran because it died instead.
  Effect.catchAll((error) => Effect.succeed({ caught: true as const, error }))
)

Effect.runPromise(program).then(
  // After fix: { caught: true, error: SqlError }
  (result) => console.log(result),
  // Before fix: reject here (defect), not caught above.
  (err) => console.error("Died (not caught)", err)
)

Related

  • Related Issue #
  • Closes #

@0xh3x 0xh3x requested a review from tim-smart as a code owner February 8, 2026 09:21
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Feb 8, 2026
@changeset-bot
Copy link

changeset-bot bot commented Feb 8, 2026

🦋 Changeset detected

Latest commit: 7dc6ab1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/sql-sqlite-bun Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

1 participant