Skip to content

fix: cold start only on on-demand invocation#2317

Closed
Attyuttam wants to merge 7 commits into
aws-powertools:mainfrom
Attyuttam:main
Closed

fix: cold start only on on-demand invocation#2317
Attyuttam wants to merge 7 commits into
aws-powertools:mainfrom
Attyuttam:main

Conversation

@Attyuttam

Copy link
Copy Markdown
Contributor

Summary

Changes

Fixes #2113 - cold start only for on-demand invocation type else its not considered


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi
dreamorosi requested a review from phipag November 26, 2025 10:51
@dreamorosi
dreamorosi removed the request for review from phipag November 26, 2025 10:51

@dreamorosi dreamorosi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Attyuttam thank you for the PR.

Before we can start with the review, please make sure that the project still compiles after having made changes. Currently the CI is failing across the board.

If you have questions, please let us know.

@phipag

phipag commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

@Attyuttam The CI fails due to broken unit tests. You can run locally mvn clean test to verify tests before updating the PR.

My suggestion is to update the failing unit test by setting the environment variable you are checking for. You can use @SetEnvironmentVariable for this. Here is an example of a test doing something similar:

https://github.com/Attyuttam/powertools-lambda-java/blob/090de1d6d2d34f87820d242bc3a81a28d7945291/powertools-common/src/test/java/software/amazon/lambda/powertools/common/internal/LambdaHandlerProcessorTest.java#L150-L159

@Attyuttam

Attyuttam commented Nov 27, 2025

Copy link
Copy Markdown
Contributor Author

Still working on this, there are a lot of test failures due to the code change, will update and drop a message here !
Apologies for the delay, new to the ecosystem.

@phipag
phipag self-requested a review November 27, 2025 10:05
@phipag

phipag commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

No worries, feel free to reach out if you have any questions. Your work on this is much appreciated 👍

@phipag

phipag commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

@Attyuttam For the other tests that are failing, most likely the issue will be resolved if you configure in pom.xml the Maven Surefire configuration to set the initialization type env var to on-demand. In this case, the cold start behavior should be exactly the same as before and the unit tests should pass for the other modules that are failing.

@Attyuttam

Copy link
Copy Markdown
Contributor Author

Ohh, okay. I was manually setting using the @SetEnvironmentVariable annotation on every test, I was about to ask this here. Thanks for the suggestion.

@Attyuttam

Copy link
Copy Markdown
Contributor Author

the powertools-idempotency-dynamodb module was failing in mvn clean test. Although, when the tests were run independently, they passed.

I looked at the blog that was put in the comments but that has become invalid, so I updated that to the correct URL as well.

I tried incorporating the changes based on the latest blog by nickolas fisher, but it did not work. Can you please help me out here

@sonarqubecloud

Copy link
Copy Markdown

@phipag phipag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Attyuttam! Apologies for the late reply, I am back from travels now.

I left some comments below. I think the dynamodb test as well as some of the logging assertions are failing due to your operating system (I assume it is Windows?). Currently, the project is optimized to run on unix-like systems. Do you have the possibility to run this on WSL or a unix-like machine? If not, I am happy to verify your changes on my computer and send potential last changes myself manually. Let me know how you want to proceed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file. (the addition of \r)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file. (the addition of \r)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file.

Comment thread pom.xml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file. This is not needed in the parent pom. Please make sure to add it in the corresponding module poms such as all the logging modules.

@Attyuttam

Copy link
Copy Markdown
Contributor Author

Hey @phipag ! hope you had a good time !! It would be great if you could run it in your system, I unfortunately have a windows machine

@phipag

phipag commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Thanks @Attyuttam. I moved over your commits to this PR (because I don't have permission on your fork): #2329.

I will make sure your contribution is recognized with your account! Thanks again!

Please feel free to comment / approve this PR.

@phipag phipag closed this Dec 11, 2025
@phipag

phipag commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Support correct cold start detection for non-on-demand invocation types

3 participants