Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/network/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class Connection extends EventEmitter {
this.#correlationId = 0
this.#nextMessage = 0
this.#afterDrainRequests = []
this.#requestsQueue = fastq((op, cb) => op(cb), this.#options.maxInflights!)
this.#requestsQueue = fastq((op, cb) => op(cb), this.#options.maxInflights! ?? defaultOptions.maxInflights!)
this.#inflightRequests = new Map()
this.#responseBuffer = new DynamicBuffer()
this.#responseReader = new Reader(this.#responseBuffer)
Expand Down
20 changes: 20 additions & 0 deletions test/clients/base/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,3 +750,23 @@ test('kPerformWithRetry should not leak timers', async t => {
strictEqual(error.errors.length, 2)
ok(error.errors[1].message.startsWith('Client closed while retrying'))
})

test('initialization should not fail when maxInflights is specifically set to undefined', async t => {
const client = createBase(t, { maxInflights: undefined })

// Create a promise that resolves when metadata event is emitted
const metadataPromise = new Promise<ClusterMetadata>(resolve => {
client.on('client:metadata', resolve)
})

// Trigger metadata fetch
client.metadata({ topics: [] })

// Wait for the event
const metadata = await metadataPromise

// Verify metadata structure
strictEqual(typeof metadata.id, 'string')
strictEqual(metadata.brokers instanceof Map, true)
strictEqual(metadata.topics instanceof Map, true)
})