Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix checking for pending requests in an infinite loop WIP #1703

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 0 deletions src/network/requestQueue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ module.exports = class RequestQueue extends EventEmitter {
this[PRIVATE.EMIT_QUEUE_SIZE_EVENT]()
}

// if (this.pending.length) {
this.scheduleCheckPendingRequests()
// }
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/network/requestQueue/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,21 @@ describe('Network > RequestQueue', () => {
expect(request.entry.resolve).toHaveBeenCalledWith(expect.objectContaining({ size, payload }))
})

it('does not start checking for pending requests needlessly (in an infinite loop)', async () => {
const checkPendingRequests = jest.spyOn(requestQueue, 'checkPendingRequests')

// fulfill request is called as soon as the connection starts, so
// this emulates the beginning of a successful connection to the cluster
requestQueue.fulfillRequest({
correlationId: request.entry.correlationId,
payload,
size,
})

await sleep(1000)
expect(checkPendingRequests).toHaveBeenCalledTimes(1)
})

describe('when there are pending requests', () => {
beforeEach(() => {
while (requestQueue.inflight.size < requestQueue.maxInFlightRequests) {
Expand Down
Loading