Skip to content

SystemError: (11, 'Resource temporarily unavailable') when reading files from LocalStorageService under concurrency #12414

Description

@luiishi

Bug Description

Under concurrent execution, Langflow intermittently fails when attempting to read recently saved files from the local storage service. The error originates from asynchronous file access using aiofile and results in:
SystemError: (11, 'Resource temporarily unavailable')
This occurs even when the file has been successfully written moments before.

Environment

  • Langflow version: 1.8.3
  • OS: Ubuntu (Linux kernel 6.8.x)
  • Python: 3.12
  • Storage backend: Local filesystem (~/.cache/langflow)
  • Execution mode: concurrent flows / multiple workers (4)

Additional Observations

  • The error consistently originates from aiofile / caio during async file access

  • Stack trace shows failure during context creation in async I/O layer

  • Files are stored under:
    ~/.cache/langflow/<flow_id>/<filename>

  • System-level limits do not appear to be the cause:

    • High ulimit -n (≈1M)
    • Low disk utilization
    • No filesystem or kernel errors in dmesg
    • 8gb ram
    • 4 cores
    • 100GB SSD

Logs:

Traceback (most recent call last):
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/custom/custom_component/component.py", line 1136, in build_results
return await self._build_with_tracing()
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/custom/custom_component/component.py", line 1118, in _build_with_tracing
results, artifacts = await self._build_results()
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/custom/custom_component/component.py", line 1163, in _build_results
result = await self._get_output_result(output)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/custom/custom_component/component.py", line 1238, in _get_output_result
result = await method() if inspect.iscoroutinefunction(method) else await asyncio.to_thread(method)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/base/models/model.py", line 89, in text_response
result = await self.get_chat_result(...)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/base/models/model.py", line 217, in get_chat_result
return await self._get_chat_result(...)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/base/models/model.py", line 269, in _get_chat_result
messages.append(input_value.to_lc_message(self.name))
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/schema/message.py", line 184, in to_lc_message
file_contents = self.get_file_content_dicts(model_name)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/schema/message.py", line 256, in get_file_content_dicts
content_dicts.append(create_image_content_dict(file, None, model_name))
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/utils/image.py", line 93, in create_image_content_dict
data_url = create_data_url(image_path, mime_type)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/utils/image.py", line 70, in create_data_url
base64_data = convert_image_to_base64(image_path)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/utils/image.py", line 35, in convert_image_to_base64
file_content = run_until_complete(...)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/utils/async_helpers.py", line 42, in run_until_complete
return future.result()
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/lfx/utils/async_helpers.py", line 36, in run_in_new_loop
return new_loop.run_until_complete(coro)
File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/langflow/services/storage/local.py", line 147, in get_file
async with async_open(str(file_path), "rb") as f:
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/aiofile/utils.py", line 341, in async_open
afp = AIOFile(str(file_specifier), mode, *args, **kwargs)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/aiofile/aio.py", line 130, in init
self.__context = context or get_default_context()
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/aiofile/aio.py", line 329, in get_default_context
return create_context()
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/aiofile/aio.py", line 311, in create_context
context = caio.AsyncioContext(max_requests, loop=loop)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/caio/asyncio_base.py", line 22, in init
self.context = self._create_context(max_requests, **kwargs)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/caio/linux_aio_asyncio.py", line 10, in _create_context
context = super()._create_context(max_requests)
File "/home/USUARIO/proyectos/langflow-1.8.3/langflow-venv/lib/python3.12/site-packages/caio/asyncio_base.py", line 25, in _create_context
return self.CONTEXT_CLASS(max_requests=max_requests, **kwargs)
System
Error: (11, 'Resource temporarily unavailable')

Logs from execution:

2026-03-31T13:30:28.930472Z [info ] File 2026-03-31_13-30-28_doc432_sheet962_areafull.png saved successfully in flow 1b43f09c-d925-4dc7-abbd-d7ee54573f1b. serialized=b'{"timestamp":"2026-03-31T13:30:28.930472Z","message":"File 2026-03-31_13-30-28_doc432_sheet962_areafull.png saved successfully in flow 1b43f09c-d925-4dc7-abbd-d7ee54573f1b.","level":"INFO","module":""}'
2026-03-31T13:30:29.241192Z [info ] File 2026-03-31_13-30-29_doc432_sheet962_arealine_data_table_padded.png saved successfully in flow b289bf71-2276-4e72-baeb-c2d56cef121d. serialized=b'{"timestamp":"2026-03-31T13:30:29.241192Z","message":"File 2026-03-31_13-30-29_doc432_sheet962_arealine_data_table_padded.png saved successfully in flow b289bf71-2276-4e72-baeb-c2d56cef121d.","level":"INFO","module":""}'
2026-03-31T13:30:29.514422Z [error ] Error reading image file: (11, 'Resource temporarily unavailable') serialized=b'{"timestamp":"2026-03-31T13:30:29.514422Z","message":"Error reading image file: (11, 'Resource temporarily unavailable')","level":"ERROR","module":""}'
2026-03-31T13:30:29.534374Z [error ] Error building Component serialized=b'{"timestamp":"2026-03-31T13:30:29.534374Z","message":"Error building Component","level":"ERROR","module":""}'
2026-03-31T13:30:29.534673Z [error ] Task GoogleGenerativeAIModel-MWD0x Run 0 failed with exception: Type is not JSON serializable: SystemError serialized=b'{"timestamp":"2026-03-31T13:30:29.534673Z","message":"Task GoogleGenerativeAIModel-MWD0x Run 0 failed with exception: Type is not JSON serializable: SystemError","level":"ERROR","module":""}'
2026-03-31T13:30:29.534883Z [error ] Error executing tasks in layer 1 serialized=b'{"timestamp":"2026-03-31T13:30:29.534883Z","message":"Error executing tasks in layer 1","level":"ERROR","module":""}'
2026-03-31T13:30:29.561507Z [info ] File 2026-03-31_13-30-29_doc432_sheet962_areafull.png saved successfully in flow eb8942bf-2c79-4b80-ad63-132f5e3c0459. serialized=b'{"timestamp":"2026-03-31T13:30:29.561507Z","message":"File 2026-03-31_13-30-29_doc432_sheet962_areafull.png saved successfully in flow eb8942bf-2c79-4b80-ad63-132f5e3c0459.","level":"INFO","module":""}'
2026-03-31T13:30:29.896158Z [error ] Error reading image file: (11, 'Resource temporarily unavailable') serialized=b'{"timestamp":"2026-03-31T13:30:29.896158Z","message":"Error reading image file: (11, 'Resource temporarily unavailable')","level":"ERROR","module":""}'
2026-03-31T13:30:29.904573Z [error ] Error building Component serialized=b'{"timestamp":"2026-03-31T13:30:29.904573Z","message":"Error building Component","level":"ERROR","module":""}'
2026-03-31T13:30:29.904809Z [error ] Task GoogleGenerativeAIModel-ilG30 Run 0 failed with exception: Type is not JSON serializable: SystemError serialized=b'{"timestamp":"2026-03-31T13:30:29.904809Z","message":"Task GoogleGenerativeAIModel-ilG30 Run 0 failed with exception: Type is not JSON serializable: SystemError","level":"ERROR","module":""}'
2026-03-31T13:30:29.905049Z [error ] Error executing tasks in layer 1 serialized=b'{"timestamp":"2026-03-31T13:30:29.905049Z","message":"Error executing tasks in layer 1","level":"ERROR","module":""}'
2026-03-31T13:30:29.966380Z [info ] File 2026-03-31_13-30-29_doc432_sheet963_arealabel_table.png saved successfully in flow d999268d-f37a-4141-a8a9-0e0db6e31366. serialized=b'{"timestamp":"2026-03-31T13:30:29.966380Z","message":"File 2026-03-31_13-30-29_doc432_sheet963_arealabel_table.png saved successfully in flow d999268d-f37a-4141-a8a9-0e0db6e31366.","level":"INFO","module":""}'
2026-03-31T13:30:30.262750Z [error ] Error reading image file: (11, 'Resource temporarily unavailable') serialized=b'{"timestamp":"2026-03-31T13:30:30.262750Z","message":"Error reading image file: (11, 'Resource temporarily unavailable')","level":"ERROR","module":""}'
2026-03-31T13:30:30.272011Z [error ] Error building Component serialized=b'{"timestamp":"2026-03-31T13:30:30.272011Z","message":"Error building Component","level":"ERROR","module":""}'
2026-03-31T13:30:30.272247Z [error ] Task GoogleGenerativeAIModel-pxv0E Run 0 failed with exception: Type is not JSON serializable: SystemError serialized=b'{"timestamp":"2026-03-31T13:30:30.272247Z","message":"Task GoogleGenerativeAIModel-pxv0E Run 0 failed with exception: Type is not JSON serializable: SystemError","level":"ERROR","module":""}'

Reproduction

  1. Create a flow that:
    • generates and saves an image/file
    • immediately passes it to another node that reads it
  2. Run with concurrent executions or multiple workers
  3. After ~150-200 runs starts to fail continuosly, the following executions keep failing.

Expected behavior

Run without errors with 4-8 workers.

Who can help?

No response

Operating System

24.04

Langflow Version

1.8.3

Python Version

3.12

Screenshot

Image

Flow File

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingjiraThis issue has been logged in Jira for fix by the engineering team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions