fix: Get responseBodySize from body if content-length is missing#1793
Merged
Conversation
Supportability Metric Usage Changes:No matching changes found Supportability Metrics .md File Changes:supportability_metrics.md was changed? New supportability metrics require changes to supportability_metrics.md, as well as a new PR to Angler. Please ensure an Angler PR is created and linked to this PR. |
Asset Size Report
Merging this pull request will result in the following asset size changes:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1793 +/- ##
==========================================
+ Coverage 88.90% 89.45% +0.55%
==========================================
Files 213 213
Lines 7859 7864 +5
Branches 1654 1657 +3
==========================================
+ Hits 6987 7035 +48
+ Misses 776 746 -30
+ Partials 96 83 -13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ellisong
approved these changes
Jun 15, 2026
ellisong
left a comment
Contributor
There was a problem hiding this comment.
looks fine to me if tests pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses an issue where AjaxRequest events inaccurately reported a
responseSizeof 0 orundefineddue to a lack of fallback mechanisms and overly restrictive falsy checks. Introduced a fallback mechanism that calculates response sizes from captured payloads for Fetch and XHR requests when thecontent-lengthheader is missing.Overview
This pull request resolves multiple edge cases where Ajax request
responseSizetracking failed or defaulted toundefinedinstead of accurately reflecting the payload size.Key Changes:
dataSize()Utility Bug: Adjustedsrc/common/util/data-size.jsto ensure empty strings return0instead of falling through toundefined.onFetchDoneand XHRendhandlers to measure the captured response body payload when thecontent-lengthheader or primary detection is missing (operational when payload capture is enabled).if (!value)blocks with explicitif (value !== undefined)validation to ensure valid0sizes (e.g., 204 No Content responses) are not blocked or omitted.instrument.test.jswith integration tests utilizing real XMLHttpRequest objects to execute actual instrumentation flows.Related Issue(s)
https://new-relic.atlassian.net/browse/NR-446528
Testing
Execute the following commands in your local development environment to verify the fixes and ensure no regressions exist: