Retry requests with different headers and etc
# crawlee-js
m
Can we get this page also in JS version: https://crawlee.dev/python/docs/guides/error-handling Also I am interested regarding best practices how to change headers when 403 or 429 are encountered, so I don't repeat same request with same headers and different IP only
a
message has been deleted
o
Hi, thanks for your questions. Headers rotation part: First you need to have a pool of header sets and a getter logic to use afterwards (randomised or index based). That you can achieve manually or by employing a package like header-generator. If you want to keep track of used header sets inside of your pool, you can use request.retryCount. Then, if your Actor handles request sending automatically, you can adjust the headers in errorHandler once one of mentioned errors occurs. You can also remove 403 and 429 from the the list of blocked statuses under sessionPoolOptions, in this case you could add headers rotation inside requestHandler, don't forget to throw exception afterwards, so the request is retried. I f you use BasicCrawler, you will simply get a new set of headers every time you send request inside of requestHandler. Documentation part: I'll reach out to our team to share your interest in mentioned documentation page.
m
hey @Olexandra thanks for feedback, I implemented something, I'll get back you on this later
can we enforce on user max memory for PPR actors or they can override it:
bascially as I can see over API they can override my 512, but I don't want to allow that
m
Hey @memo23, there is a way, check
maxMemoryMbytes
in actor.json [docs](https://docs.apify.com/platform/actors/development/actor-definition/actor-json) This way, you prevent users from overriding memory with higher values, and API requests memory will be clamped to specified value (if higher) and the run will still start. https://cdn.discordapp.com/attachments/1437950792828190791/1440279293325217877/image.png?ex=691d941e&is=691c429e&hm=6590bd3f7a46b82f46c6b9412b4b9a7973488c93fd5f32ab7511fa5c1535be1d&
m
I know thatfor PPE, can we use also for PPR?
m
Hey, I don't see a reason why not; it shouldn't be connected to the pricing model. Anyway, you can try it, right?
m
ok, I will for sure