Skip to content

Commit

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

* fix: ensure default timeout 5 seconds

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
  • Loading branch information
dj12djdjs and ankush committed Jun 18, 2023
1 parent ae0edd8 commit 62a3a70
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 @@ -17,6 +17,7 @@
"html_condition",
"sb_webhook",
"request_url",
"timeout",
"is_dynamic_url",
"cb_webhook",
"request_method",
Expand Down Expand Up @@ -204,6 +205,14 @@
"fieldname": "is_dynamic_url",
"fieldtype": "Check",
"label": "Is Dynamic URL?"
},
{
"default": "5",
"description": "The number of seconds until the request expires",
"fieldname": "timeout",
"fieldtype": "Int",
"label": "Request Timeout",
"reqd": 1
}
],
"links": [
Expand All @@ -212,7 +221,7 @@
"link_fieldname": "webhook"
}
],
"modified": "2023-06-02 17:25:12.598232",
"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 @@ -129,7 +129,7 @@ def enqueue_webhook(doc, webhook) -> None:
url=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 62a3a70

Please sign in to comment.