Skip to content

[Version: 2.2.2] Server crashes with OOM during file upload and virus scanning #263

@vlovini

Description

@vlovini

Description:
When uploading a file using the cap-js/attachments plugin, the server crashes due to an out-of-memory (OOM) error during the virus scanning phase. This happens consistently with large files.

Expected Behavior:
The server should handle file uploads and virus scanning without exceeding memory limits or crashing.

Actual Behavior:

  • Server memory usage spikes from ~250MB (idle) to 2.3GB during virus scanning.
  • The process is killed with exit code 137 (OOM).
  • No error is returned to the client; the request appears to succeed (204), but the server crashes shortly after.

Steps to Reproduce:

  1. Start the CAP server with the cap-js/attachments plugin enabled.
  2. Upload a large file (e.g., ~350MB) to an entity with an attachment field.
  3. Observe server memory usage during the upload and virus scanning.
  4. Server crashes with OOM.

Before:
Image

After:
Image

Logs:

2025-10-09T16:42:20.142+0000 [RTR/41] STDOUT ... "PUT /odata/v1/TaskService/Tasks_attachments(...) HTTP/1.1" 204 ...
...
2025-10-09T16:42:39.736+0000 [APP/PROC/WEB/0] STDERR Killed
2025-10-09T16:42:41.364+0000 [APP/PROC/WEB/0] STDERR npm verbose exit 137
2025-10-09T16:42:41.364+0000 [APP/PROC/WEB/0] STDERR npm verbose code 137

Environment:

  • Node.js: v22.5.0
  • npm: v10.8.2
  • CDS Version: 8.9.4
  • OS: Linux 5.15.0-153-generic
  • Platform: SAP BTP Cloud Foundry
  • Plugin: cap-js/attachments

Additional Context:

  • The issue seems to be related to the virus scanning step.
  • Might be related to how the file is buffered or streamed in memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions