Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError in Vercel Serverless Functions deployment #315

Open
taesungh opened this issue Jan 15, 2024 · 0 comments
Open

OSError in Vercel Serverless Functions deployment #315

taesungh opened this issue Jan 15, 2024 · 0 comments

Comments

@taesungh
Copy link

Hello,

My team has a Python ASGI application (specifically FastAPI) deployed on Vercel Serverless Functions which uses AWS Lambda internally. Vercel's Python Runtime for ASGI is based on Mangum as noted in vercel/vercel/packages/python/vc_init.py:173-175 with a very similar runner system of running the ASGI app instance as mangum.protocols.HTTPCycle.__call__.

The API works great most of the time but sporadically encounters a runtime issue causing requests to fail every now and then.

[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 /var/task/vc__handler__python.py refers to vc_init.py.

The only fix we found is redeploying our project on Vercel to create a new deployment, but this is only temporary, and the issue resurfaces every now and then, especially when traffic is high.

Any thoughts on what might be the root cause?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant