Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 8a55a4c

Browse files
committed
refactor(pushqueue): Tidy cleanup.
1 parent 7c255bc commit 8a55a4c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/utils/PushQueue.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,21 +234,22 @@ export default class PushQueue<T> {
234234
}
235235

236236
async _cleanup() {
237+
const { error, nextQueue } = this
237238
this.finished = true
238-
const { error } = this
239-
const queue = this.nextQueue
240239
this.error = undefined
241-
this.nextQueue = []
242240
this.pending = 0
243241
this.buffer.length = 0
244-
while (queue.length) {
245-
const p = queue.shift()
242+
this.buffer = []
243+
this.nextQueue = []
244+
const doneValue = { value: undefined, done: true }
245+
while (nextQueue.length) {
246+
const p = nextQueue.shift()
246247
if (!p) { continue }
247248

248249
if (error) {
249250
p.reject(error)
250251
} else {
251-
p.resolve(undefined)
252+
p.resolve(doneValue)
252253
}
253254
}
254255

test/memory/MessageQuantity.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ describe('no memleaks when processing a high quantity of large messages', () =>
223223
}, MAX_TEST_TIME * 2)
224224
})
225225

226-
test('resend', async () => {
226+
test('just resend', async () => {
227227
const MAX_MEMORY_USAGE = 5e+8 // 500MB
228228
const MAX_MESSAGES = 60000 // 60k
229229
const end = 1616509054932

0 commit comments

Comments
 (0)