EROFS error when hitting lambda function endpoint

1.3k Views Asked by At

I have deployed my expressjs code to lambda using claudiajs.When I hit the API endpoint generated every alternate request gives me internal server error.I checked the logs and found this

 "errorType": "Error",
    "errorMessage": "EROFS: read-only file system, mkdir '/var/task/logs'",
    "code": "EROFS",
    "stack": [
        "Error: EROFS: read-only file system, mkdir '/var/task/logs'"
    ],
    "cause": {
        "errorType": "Error",
        "errorMessage": "EROFS: read-only file system, mkdir '/var/task/logs'",
        "code": "EROFS",
        "stack": [
            "Error: EROFS: read-only file system, mkdir '/var/task/logs'"
        ],
        "errno": -30,
        "syscall": "mkdir",
        "path": "/var/task/logs"
    },
    "isOperational": true,
    "errno": -30,
    "syscall": "mkdir",
    "path": "/var/task/logs"
}

I am not able to figure out what could be the issue and why is it occurring only on alternate requests and not every request.How do I go on about it? Any help would be appreciated.

2

There are 2 best solutions below

0
Atul Sharma On

Lambda dosen't allow you to write the space allocated to you.

Since, you are trying to create a directory may be to write logs, so its giving you the error.

To write application logs with lambda you can use AWS Cloudwatch log streaming.

https://www.npmjs.com/package/lambda-log

2
Oleksandr Lykhonosov On

You can use /tmp directory for some temporary files, but there is also a limit 512Mb.

24 MAR 2022 update:
AWS Lambda now allows you to configure ephemeral storage (/tmp) between 512 MB and 10,240 MB. You can continue to use up to 512 MB for free and are charged for the amount of storage you configure over the free limit for the duration of invokes.

Check these links:

AWS Lambda Limits
Accessing Amazon CloudWatch Logs for AWS Lambda
AWS Lambda Now Supports Up to 10 GB Ephemeral Storage