diff --git a/packages/apify/src/actor.ts b/packages/apify/src/actor.ts index 41f3c7275b..d83143d821 100644 --- a/packages/apify/src/actor.ts +++ b/packages/apify/src/actor.ts @@ -818,7 +818,12 @@ export class Actor { this._ensureActorInit('openRequestQueue'); - return this._openStorage(RequestQueue, queueIdOrName, options); + const queue = await this._openStorage(RequestQueue, queueIdOrName, options); + + // eslint-disable-next-line dot-notation + queue['initialCount'] = (await queue.client.get())?.totalRequestCount ?? 0; + + return queue; } /** diff --git a/test/apify/actor.test.ts b/test/apify/actor.test.ts index 97d11fa543..6f732a5c05 100644 --- a/test/apify/actor.test.ts +++ b/test/apify/actor.test.ts @@ -604,10 +604,15 @@ describe('Actor', () => { const queueId = 'abc'; const options = { forceCloud: true }; const openStorageSpy = vitest.spyOn(StorageManager.prototype, 'openStorage'); - openStorageSpy.mockImplementationOnce(async (i) => i); - await sdk.openRequestQueue(queueId, options); + + const mockRQ = { client: { get: () => ({ totalRequestCount: 10 }) } }; + + openStorageSpy.mockImplementationOnce(async () => mockRQ); + const queue = await sdk.openRequestQueue(queueId, options); expect(openStorageSpy).toBeCalledWith(queueId, sdk.apifyClient); expect(openStorageSpy).toBeCalledTimes(1); + + expect(queue.initialCount).toBe(10); }); test('openDataset should open storage', async () => {