Skip to content

DeadContext handling#39

Merged
mxsnq merged 4 commits intoispras:masterfrom
MatthewZMSU:master
Dec 8, 2023
Merged

DeadContext handling#39
mxsnq merged 4 commits intoispras:masterfrom
MatthewZMSU:master

Conversation

@MatthewZMSU
Copy link
Contributor

Description

Added handling the no-context exception, so now in Scrapy-puppeteer we do not Retry 3 times the same page and context.

Type of change

Please delete options that are not relevant.

  • [+] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Tested manually with Scrapy spider

  • Tested with Scrapy-puppeteer auto-tests

  • My code follows the style guidelines of this project

  • I have performed a self-review of my code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation

  • My changes generate no new warnings

Comment on lines +23 to 29
} else { // No context. Possibly, our service was restarted
res.status(422);

res.send({
error: errorMessage
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works well, but I'm not sure we should treat every error outside action calls as 422. For example, if a context/page creation fails, it is a server issue and we might want to reply with 500+. Maybe we should reply with 422 only on "context/page not found" errors? We can create a custom error type for that.


if (contextId) {
res.header('scrapy-puppeteer-service-context-id', contextId);
} // What if contextId is undefined? Maybe we should skip such situations...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Now we response with not only 422 but also with 500
@MatthewZMSU
Copy link
Contributor Author

Now we recognise _Page/Conext_NotFound errors, but we still do not recognize e.g. "Error: No element found for selector" as client's error (we treat this as 500). May be this is future work.

set status and send response
@mxsnq mxsnq merged commit cc6ff31 into ispras:master Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants