Apify Discord Mirror

Updated last year

Expire requests from request queue

At a glance

The community member has a use case where they need to handle request expiration in the RequestQueue after a specified time (e.g., 30 minutes). They propose a possible approach of setting an epoch time in the userData when enqueuing a request, and then checking the elapsed time against the specified limit in the preNavigationHooks phase, throwing a NonRetryableError to prevent further processing of the request. However, they note that this approach may not be the most elegant solution and has the side effect of creating a page object, which in turn opens a browser and creates an empty tab, consuming unnecessary resources. The community member is looking for a more efficient and cleaner way to handle request expiration and avoid the overhead of using resources.

In the comments, another community member suggests that the proposed approach is a good one and the best that can be done in the current scenario.

Hello,

I have a use case where I need to handle request expiration in the RequestQueue after a specified time (e.g., 30 minutes). Is this achievable in the current scenario?

One possible approach is to set an epoch time in the userData when enqueuing a request. Then, when it reaches the preNavigationHooks phase, you can check the elapsed time against the specified limit and throw a NonRetryableError to prevent further processing of the request.

However, this approach may not be the most elegant solution, and it has the side effect of creating a page object, which in turn opens a browser and creates an empty tab, consuming unnecessary resources.

Is there a more efficient and cleaner way to handle request expiration and avoid the overhead of using resources?
R
1 comment
hey! this is a good approach and the best you can do in this case
Add a reply
Sign up and join the conversation on Discord