Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions webhook_server/libs/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def __init__(self, hook_data: dict[Any, Any], headers: Headers, logger: logging.
)

async def process(self) -> Any:
time.sleep(240)
Comment on lines 155 to +156
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical issue: Synchronous sleep in async method will block the event loop

Adding a 4-minute synchronous sleep at the beginning of an asynchronous method will block the entire event loop, preventing the processing of other events and potentially causing webhook timeouts.

If you need to implement a delay for testing purposes, use an asynchronous sleep instead:

-        time.sleep(240)
+        import asyncio
+        await asyncio.sleep(240)

However, I strongly caution against any long delays in webhook handlers, as:

  1. GitHub webhooks typically time out after ~10 seconds
  2. All webhook processing will be delayed by 4 minutes
  3. Resources may be exhausted if multiple webhooks are received during this delay
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async def process(self) -> Any:
time.sleep(240)
async def process(self) -> Any:
import asyncio
await asyncio.sleep(240)

if self.github_event == "ping":
return {"status": requests.codes.ok, "message": "pong"}

Expand Down