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

fix: Fixed transaction-shim to properly create new transactions when the existing transaction is not active #2912

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

bizob2828
Copy link
Member

@bizob2828 bizob2828 commented Jan 29, 2025

Description

It seems like warm starts of lambdas leak async context in Node.js A regression was introduced here. Previously before wrapping a call in a transaction it checked for an active transaction, this changed and only checked for a transaction, not that it was active. For some reason during warm invocations of lambda, the Node.js async context(which we just leverage AsyncLocalStorage) is leaking across runs.

How to Test

I added some unit tests around transaction-shim. Also we manually tested with a patched layer in lambda and there were 8 requests made and all 8 had telemetry.

Related Issues

Closes #2910

@mrickard mrickard self-assigned this Jan 29, 2025
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.36%. Comparing base (559dc98) to head (4718794).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2912      +/-   ##
==========================================
+ Coverage   90.26%   97.36%   +7.09%     
==========================================
  Files         289      309      +20     
  Lines       45807    47408    +1601     
==========================================
+ Hits        41347    46157    +4810     
+ Misses       4460     1251    -3209     
Flag Coverage Δ
integration-tests-cjs-18.x 73.12% <0.00%> (+<0.01%) ⬆️
integration-tests-cjs-20.x 73.11% <0.00%> (-0.02%) ⬇️
integration-tests-cjs-22.x 73.14% <0.00%> (-0.02%) ⬇️
integration-tests-esm-18.x 49.81% <0.00%> (?)
integration-tests-esm-20.x 49.82% <0.00%> (-0.01%) ⬇️
integration-tests-esm-22.x 49.87% <0.00%> (-0.01%) ⬇️
unit-tests-18.x 89.12% <100.00%> (+<0.01%) ⬆️
unit-tests-20.x 89.12% <100.00%> (+<0.01%) ⬆️
unit-tests-22.x 89.12% <100.00%> (+<0.01%) ⬆️
versioned-tests-18.x 79.22% <83.33%> (?)
versioned-tests-20.x 79.23% <83.33%> (?)
versioned-tests-22.x 79.24% <83.33%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bizob2828 bizob2828 merged commit 3ad8c59 into newrelic:main Jan 29, 2025
30 checks passed
@bizob2828 bizob2828 deleted the lambda-end-tx branch January 29, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done: Issues recently completed
Development

Successfully merging this pull request may close these issues.

v12.11.0 and later not properly handling warm starts of lambda invocations
2 participants