Skip to content

fix: Fixed Azure functions crashing when they include response headers - #4070

Merged
jsumners-nr merged 2 commits into
newrelic:mainfrom
jsumners-nr:issue-4062
Jun 25, 2026
Merged

fix: Fixed Azure functions crashing when they include response headers#4070
jsumners-nr merged 2 commits into
newrelic:mainfrom
jsumners-nr:issue-4062

Conversation

@jsumners-nr

Copy link
Copy Markdown
Contributor

When an Azure function includes headers in the response object, our instrumentation was crashing at:

segment.addSpanAttribute(attributeName, header)

This is because the segment was unavailable at:

const segment = transaction.agent.tracer.getSegment()

The root cause is that our transaction finalization was not happening within the right context.

strategy:
fail-fast: false
matrix:
node-version: [22.x, 24.x]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jsumners-nr
jsumners-nr marked this pull request as ready for review June 25, 2026 17:09
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.06%. Comparing base (db6e4e3) to head (61a8110).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
.../subscribers/azure-functions/azure-handler-base.js 0.00% 16 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (db6e4e3) and HEAD (61a8110). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (db6e4e3) HEAD (61a8110)
versioned-tests-22.x 1 0
versioned-tests-24.x 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4070      +/-   ##
==========================================
- Coverage   97.41%   90.06%   -7.36%     
==========================================
  Files         514      501      -13     
  Lines       61727    59885    -1842     
  Branches        1        1              
==========================================
- Hits        60133    53934    -6199     
- Misses       1594     5951    +4357     
Flag Coverage Δ
integration-tests-cjs-22.x 73.64% <0.00%> (-0.02%) ⬇️
integration-tests-cjs-24.x 74.25% <0.00%> (-0.02%) ⬇️
integration-tests-esm-22.x 54.00% <0.00%> (-0.02%) ⬇️
integration-tests-esm-24.x 55.17% <0.00%> (-0.02%) ⬇️
unit-tests-22.x 89.09% <0.00%> (-0.02%) ⬇️
unit-tests-24.x 89.09% <0.00%> (-0.02%) ⬇️
versioned-tests-22.x ?
versioned-tests-24.x ?

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jsumners-nr
jsumners-nr merged commit c88d2b7 into newrelic:main Jun 25, 2026
34 of 42 checks passed
@github-project-automation github-project-automation Bot moved this from Needs PR Review to Done: Issues recently completed in Node.js Engineering Board Jun 25, 2026
@jsumners-nr
jsumners-nr deleted the issue-4062 branch June 25, 2026 17:20
@github-actions github-actions Bot mentioned this pull request Jun 25, 2026
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.

Azure Functions subscriber crashes with "Cannot read properties of null (reading 'addSpanAttribute')" on any HTTP response with collected headers

3 participants