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

Errors from handler are not returned to stdout #411

Closed
Thorleon opened this issue Nov 24, 2021 · 2 comments
Closed

Errors from handler are not returned to stdout #411

Thorleon opened this issue Nov 24, 2021 · 2 comments

Comments

@Thorleon
Copy link

Is your feature request related to a problem? Please describe.
Hello,
in our stack we used to work on go1.x runtime, but recently we switched to provided.al2 according to https://aws.amazon.com/blogs/compute/migrating-aws-lambda-functions-to-al2/ . After successful deploy we noticed shortage of logs in CloudWatch. It turns out that errors returned from handler are not visible in CW. I have run https://hub.docker.com/r/amazon/aws-lambda-provided and it seems like error message is not put on stdout/stderr as it was in go1.x.

Describe the solution you'd like
Probably one line with logging should be enough:

	if functionResponse.Error != nil {
		log.Printf("%v", functionResponse.Error) // <- NEW LINE
		payload := safeMarshal(functionResponse.Error)
		if err := invoke.failure(payload, contentTypeJSON); err != nil {
			return fmt.Errorf("unexpected error occurred when sending the function error to the API: %v", err)
		}
		if functionResponse.Error.ShouldExit {
			return fmt.Errorf("calling the handler function resulted in a panic, the process should exit")
		}
		return nil
	}

I can create PR with the change.

@bmoffatt
Copy link
Collaborator

Thanks for reporting this. Making this consistent for those migrating between the two makes sense to me. This means there needs to be some consideration to ensure that the logging happens only for the path using the runtime API, to prevent double-logging for existing go1.x users. Also, I think the format of the logging done by the go1.x may have some quirks that'll need to be tested against to ensure consistency.

cc @carlzogh

@Thorleon
Copy link
Author

We tested latest release with the fix and works like a charm, thanks for your suport.

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

2 participants