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

Error of handler is no longer printed #890

Closed
DirkRusche-Otto opened this issue Jun 4, 2024 · 4 comments · Fixed by #892
Closed

Error of handler is no longer printed #890

DirkRusche-Otto opened this issue Jun 4, 2024 · 4 comments · Fixed by #892

Comments

@DirkRusche-Otto
Copy link

I noticed that starting with version 0.11.0 an error from a handler is no longer printed and not sent to CloudWatch logs.

The PR #845 states:

[...] Using the top-level run function should result in functionally (almost) equivalent code (except for some logging statements).

Reading this comment I guess the change in behavior is expected.
In case of an error, debugging the Lambda becomes way harder since there is no log message why and even that the Lambda failed.

Is there already a solution how to get the old behavior (error being logged) back?

How to reproduce

Example code

Example code to reproduce the issue

use lambda_runtime::{run, service_fn, LambdaEvent};
use serde::Deserialize;
use tracing::info;

#[derive(Deserialize)]
struct Request {}

#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
    lambda_runtime::tracing::init_default_subscriber();

    run(service_fn(handler)).await
}

async fn handler(_event: LambdaEvent<Request>) -> anyhow::Result<()> {
    info!("hi from handler");

    Err(anyhow::Error::msg("This log message is printed nowhere"))
}

Version >=0.11.0

If I run it with (for example) version 0.11.2 and the commands cargo lambda watch and cargo lambda invoke --data-ascii "{}" gives me the output:

INFO Lambda runtime invoke{requestId="10c0a11b-602d-418a-aff1-8931c10fd234" xrayTraceId="Root=1-665f22b0-9ba7379721f58c9124e882ff;Parent=56d52e45d9740162;Sampled=1"}: hi from handler

Version 0.10.0

If I run it with version 0.10.0 I see the error:

INFO Lambda runtime invoke{requestId="aa50b9cc-4af9-44c4-a91b-f1d89d398e1b" xrayTraceId="Root=1-665f2357-b44fa3fc478ba6def2d07857;Parent=4a2a30e259041ad1;Sampled=1"}: hi from handler
ERROR Lambda runtime invoke{requestId="aa50b9cc-4af9-44c4-a91b-f1d89d398e1b" xrayTraceId="Root=1-665f2357-b44fa3fc478ba6def2d07857;Parent=4a2a30e259041ad1;Sampled=1"}: This log message is printed nowhere
@calavera calavera mentioned this issue Jun 8, 2024
2 tasks
@calavera
Copy link
Contributor

calavera commented Jun 8, 2024

Thanks for the clear description and steps to reproduce the problem. #892 should fix it.

Copy link

github-actions bot commented Jun 8, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

@DirkRusche-Otto
Copy link
Author

Thank you for the quick fix, very appreciated.

Can you give me an ETA of when this fix will be released to cargo?

@calavera
Copy link
Contributor

Can you give me an ETA of when this fix will be released to cargo?

Probably this week. You can fetch the code from GitHub meanwhile.

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

Successfully merging a pull request may close this issue.

2 participants