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

Unhandled Promise Rejection when failing to write Error Logs #1099

Open
simOneAudi opened this issue Jun 29, 2022 · 1 comment
Open

Unhandled Promise Rejection when failing to write Error Logs #1099

simOneAudi opened this issue Jun 29, 2022 · 1 comment

Comments

@simOneAudi
Copy link

simOneAudi commented Jun 29, 2022

Expected Behavior

When using runMigration as a library function from another piece of software the expected behaviour would be, that all exceptions raised during the execution of migrations to be thrown to the caller.

Actual Behavior

We are calling runMigration from AWS Lambda functions in order to automate updates of our content models. The issue following issue occurs when an error during the execution of any migration occurs:

  1. Something goes wrong and an exception is thrown.
  2. runMigration attempts to write an error log file.
  3. That call fails with EROFS: read-only file system, open '/var/task/errors-2-1656322066050.log' as the filesystem is mounted read-only for AWS Lambda handlers.
  4. The rejection of the writeErrorsToLog promise is not caught, resulting in unhandledRejection event to be raised.
  5. The Lambda handler fails without any of the application's catch blocks to be executed.

Possible Solution

I'd suggest the following two adjustments:

  1. Handle errors thrown by writeErrorsToLog.
  2. Do not write error logs in case runMigration is not used as a CLI (shouldThrow === true).

If someone agrees with these steps, I might be able to provide a PR myself.

Steps to Reproduce

Just execute run migrations from a read-only FS or mock writeErrorsToLog to fail.

Context

Environment

AWS Lambda Container:

  • Node Version: v14.19.2
  • Package Manager Version: 6.14.17
  • Operating System: Linux 56fa0daeae18 5.10.76-linuxkit #1 SMP Mon Nov 8 10:21:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • Package Version: 4.8.1
@simOneAudi
Copy link
Author

I added a proposal on how to resolve the issue: #1113

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