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

[No QA] Update comment followup from 54110 #54229

Merged
merged 6 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions src/libs/Network/SequentialQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ function unpause() {
const numberOfPersistedRequests = PersistedRequests.getAll().length || 0;
Log.info(`[SequentialQueue] Unpausing the queue and flushing ${numberOfPersistedRequests} requests`);
isQueuePaused = false;

// A READ request will wait until all the WRITE requests are done, using the isReadyPromise promise.
// When the queue is paused and then unpaused, we call flush which by defaults recreates the isReadyPromise.
// After all the WRITE requests are done, the isReadyPromise is resolved, but since it's a new instance of promise,
// the pending READ request never received the resolved callback. That's why we don't want to recreate
// the promise when unpausing the queue.
flush(false);
neil-marcellini marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/APITest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ describe('APITests', () => {
});
});

test('Read request should not stuck when SequentialQueue is paused an resumed', async () => {
test('Read request should not stuck when SequentialQueue is paused and resumed', async () => {
// Given 2 WRITE requests and 1 READ request where the first write request pauses the SequentialQueue
const xhr = jest.spyOn(HttpUtils, 'xhr').mockResolvedValueOnce({previousUpdateID: 1});
API.write('MockWriteCommandOne' as WriteCommand, {});
Expand Down
Loading