Skip to content

Commit

Permalink
FIX: CaptureHandler PDF respects timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sanand0 committed Jul 8, 2024
1 parent cb3a38c commit aa82b6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions gramex/apps/capture/chromecapture.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ async function render(q) {
scale: parseFloat(q.scale || 1), // scale must be a double, not int
margin: {},
printBackground: true,
timeout: (q.timeout || 30) * 1000,
};
// If margins are specified, use them
let margin_keys = ["top", "right", "bottom", "left"];
Expand Down
3 changes: 3 additions & 0 deletions gramex/handlers/capturehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ def get(self):
# ?url= can be a relative URL. Use the full X-Request URL as the base
args['url'] = urljoin(self.xrequest_full_url, args['url'])

# Pass configured timeout to capture.js to await PDF generation
args['timeout'] = self.capture.timeout

if self.pattern and not re.search(self.pattern, args['url']):
error = f'{self.name}: {args["url"]} does not match pattern {self.pattern}'
raise HTTPError(BAD_REQUEST, error)
Expand Down

0 comments on commit aa82b6f

Please sign in to comment.