HackAtUCI / irvinehacks-site

Site for IrvineHacks 2024 through 2025
https://irvinehacks.com
1 stars 1 forks source link

Fix `OSError` in Vercel Serverless Functions deployment #149

Open taesungh opened 11 months ago

taesungh commented 11 months ago

Similar to HackAtUCI/HackUCI-Site#86 The API sporadically encounters a runtime issue causing requests to fail

[ERROR] OSError: [Errno 24] Too many open files
Traceback (most recent call last):
  File "/var/task/vc__handler__python.py", line 305, in vc_handler
    response = asgi_cycle(__vc_module.app, body)
  File "/var/task/vc__handler__python.py", line 201, in __call__
    loop = asyncio.new_event_loop()
  File "/var/lang/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/var/lang/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/var/lang/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/var/lang/lib/python3.9/asyncio/selector_events.py", line 53, in __init__
    selector = selectors.DefaultSelector()
  File "/var/lang/lib/python3.9/selectors.py", line 350, in __init__
    self._selector = self._selector_cls()

where vc__handler__python.py refers to Vercel's Python runtime handler.

taesungh commented 10 months ago

Submitted jordaneremieff/mangum#315 to ask if they have any thoughts.

samderanova commented 10 months ago

We might be able to set up a Vercel CRON job to automatically redeploy at a certain interval. Currently investigating this.

taesungh commented 10 months ago

Deployed temporary AWS Lambda function which runs periodically to check Axiom logs and redeploy last Vercel deployment when needed.

taesungh commented 4 months ago

It seems that while Vercel added support for Python 3.12 (including ASGI) via vercel/vercel#11675, the logic for ASGICycle in vc_init.py was updated to fit with the changes in Python 3.10

The loop parameter has been removed from most of asyncio‘s high-level API following deprecation in Python 3.8.

Perhaps upgrading to Python 3.12 on Vercel will fix the OSError issue?