Skip to content

Commit

Permalink
feat: webhook timeout (backport #21410) (#22978)
Browse files Browse the repository at this point in the history
* feat: webhook timeout (#21410)

* feat: webhook timeout

* fix: ensure default timeout 5 seconds

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
(cherry picked from commit 62a3a70)

# Conflicts:
#	frappe/integrations/doctype/webhook/webhook.json

* chore: conflicts

---------

Co-authored-by: Devin Slauenwhite <devin.slauenwhite@gmail.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
3 people committed Oct 30, 2023
1 parent db3a751 commit dbbfa17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion frappe/integrations/doctype/webhook/webhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"html_condition",
"sb_webhook",
"request_url",
"timeout",
"request_method",
"cb_webhook",
"request_structure",
Expand Down Expand Up @@ -200,10 +201,18 @@
{
"fieldname": "section_break_28",
"fieldtype": "Section Break"
},
{
"default": "5",
"description": "The number of seconds until the request expires",
"fieldname": "timeout",
"fieldtype": "Int",
"label": "Request Timeout",
"reqd": 1
}
],
"links": [],
"modified": "2022-07-11 08:54:10.740512",
"modified": "2023-06-16 10:21:00.971833",
"modified_by": "Administrator",
"module": "Integrations",
"name": "Webhook",
Expand Down
2 changes: 1 addition & 1 deletion frappe/integrations/doctype/webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def enqueue_webhook(doc, webhook) -> None:
url=webhook.request_url,
data=json.dumps(data, default=str),
headers=headers,
timeout=5,
timeout=webhook.timeout or 5,
)
r.raise_for_status()
frappe.logger().debug({"webhook_success": r.text})
Expand Down

0 comments on commit dbbfa17

Please sign in to comment.