Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`numRetries: 0` resolves to 3 retries

Open Beginner friendly
#372 0 comments 0 reactions 0 assignees View on GitHub

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
Domain
api, tooling

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:

https://github.com/typesense/typesense-js/blob/67c025cae65b08756f515ff041a70f2fa22f4d27/src/Typesense/Configuration.ts#L192-L195

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 on master at 67c025c)
  • 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

  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.

More from typesense/typesense-js

All issues in typesense/typesense-js

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.