Skip to content

fix: keep concurrency 0 so it disables the limit as documented - #364

Open
theluckystrike wants to merge 1 commit into
tursodatabase:mainfrom
theluckystrike:fix/concurrency-zero-disables-limit
Open

theluckystrike wants to merge 1 commit into
tursodatabase:mainfrom
theluckystrike:fix/concurrency-zero-disables-limit

Conversation

@theluckystrike

Copy link
Copy Markdown

Fixes #351.

Config.concurrency is documented as "set it to 0 to disable concurrency limits completely", but expandConfig did:

concurrency = Math.max(0, concurrency || 20);

0 || 20 is 20, so concurrency: 0 silently became the default limit.

Changes:

  • packages/libsql-core/src/config.ts: use concurrency ?? 20, so only a missing value takes the default. Negative values still clamp to 0.
  • packages/libsql-client/src/sqlite3.ts: the local file pool used Math.max(1, config.concurrency). Before this change it never saw 0, but with the fix above 0 would have shrunk the pool from 20 connections to 1. It now treats 0 as no connection limit, the same as the HTTP and WebSocket clients, where promise-limit already treats 0 as pass-through. In-memory databases and embedded replicas keep their single connection.
  • config.test.ts: four cases for concurrency (default, custom, 0, negative). The 0 case fails on main (expected 0, received 20) and passes with the fix.

Tests run: config.test.ts and uri.test.ts (36 passed), npm run typecheck, npm run format:check. I also opened 25 read transactions on a local file client: with concurrency: 0 all 25 open, with the default the 21st gets TRANSACTION_ACTIVE as before, and with concurrency: 2 the 3rd does.

This takes the same direction as #359, which its author closed without review.

expandConfig used `concurrency || 20`, so the documented value 0
became the default of 20. Use `??` so only a missing value takes the
default. The local sqlite3 pool turned 0 into 1 connection, so it now
treats 0 as no connection limit.

Fixes tursodatabase#351

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

concurrency: 0 is documented to disable the limit, but expandConfig turns it into 20

1 participant