`numRetries: 0` resolves to 3 retries
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
Research direction
The bug is in src/Typesense/Configuration.ts lines 192-195. Start by reading the existing logic and the linked issue #230. Run the provided reproduction script to confirm the behavior. The fix is to move the || 3 into the fallback branch of the ternary. After making the change, ensure the test suite passes; consider adding a test in test/Typesense/Configuration.spec.ts to assert that numRetries: 0 resolves to 0.
Written by the indexing model from the issue text.
Description
Bug Description
numRetries: 0 resolves to 3 retries. #230 ("fix: allow numRetries = 0") replaced || with a ternary, but the trailing || 3 still turns the ternary's 0 into 3:
this.numRetries =
(options.numRetries !== undefined && options.numRetries >= 0
? options.numRetries
: this.nodes.length + (this.nearestNode == null ? 0 : 1)) || 3;
Reproduction Steps
Run this without a server to inspect the resolved configuration:
const Typesense = require("typesense");
for (const numRetries of [undefined, 0, 1, 2]) {
const client = new Typesense.Client({
nodes: [{ host: "localhost", port: 8108, protocol: "http" }],
apiKey: "xyz",
numRetries,
});
console.log(`numRetries: ${numRetries} -> ${client.configuration.numRetries}`);
}
Expected vs Actual
numRetries passed |
Expected | Actual |
|---|---|---|
undefined |
1 (one node) | 1 |
0 |
0 | 3 |
1 |
1 | 1 |
2 |
2 | 2 |
With numRetries: 0, a timed-out request is attempted 4 times instead of once.
Environment
- Client library & version:
typesense-js v3.0.6(also onmasterat67c025c) - Node.js: v24.16.0
Additional Context
Moving || 3 into the fallback branch would preserve 0:
this.numRetries =
options.numRetries !== undefined && options.numRetries >= 0
? options.numRetries
: this.nodes.length + (this.nearestNode == null ? 0 : 1) || 3;
No test covers numRetries (test/Typesense/Configuration.spec.ts has none, and #230 changed only src/). A regression test could assert numRetries: 0 resolves to 0.
Generated with AI under the guidance of John.
- Dominant language
- TypeScript
- Stars
- 572
- Forks
- 101
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from typesense/typesense-js
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
typesense/typesense-js#374 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
typesense/typesense-js#369 ·
-
Typing for geo_distance_meters is too strictMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
typesense/typesense-js#348 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
typesense/typesense-js#324 · 1 comment ·
-
SearchResponseRequestParams doesn't match with actual API responsePossibly taken @rachit367 claimed this 152 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
typesense/typesense-js#321 · 3 comments · 1 reaction ·
All issues in typesense/typesense-js
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OpenPetsHQ/openpets#273 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
fritzprix/libr-agent#2161 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
blackboardsh/electrobun#581 ·
-
backlog-skill effort:xs frontend infra ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
LucasSantana-Dev/Lucky#2862 ·
Maintainers usually reply within 1 day