Skip to content

Commit 28578f4

Browse files
authored
fix(collector): resolved PayloadTooLargeError (#1985)
1 parent a405368 commit 28578f4

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

packages/collector/src/agentConnection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ let pidStore;
2222
// file descriptor fields in the collector announce cycle.
2323
const paddingForInodeAndFileDescriptor = 200;
2424

25-
const maxContentLength = 1024 * 1024 * 5;
25+
// NOTE: The agent/sensor has a limit of 49mb.
26+
// We had 5mb for a few years, but we were running into PayloadTooLargeError for
27+
// profiles. We increase it to 20mb and see if that helps.
28+
const maxContentLength = 1024 * 1024 * 20;
2629
let maxContentErrorHasBeenLogged = false;
2730

2831
const http = uninstrumentedHttp.http;

packages/collector/test/agentConnection_test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,34 @@ mochaSuiteFn('agent connection', function () {
119119
.catch(e => done(e));
120120
});
121121
});
122+
123+
it('should throw error if size of payload exceeds maxContentLength', done => {
124+
const bigData = 'a'.repeat(1024 * 1024 * 21);
125+
const bigSpan = {
126+
n: 'span.exit',
127+
t: 'trace-id',
128+
p: 'entry-span-id',
129+
s: 'exit-span-id',
130+
k: constants.ENTRY,
131+
data: {
132+
bigData
133+
}
134+
};
135+
const spans = [bigSpan];
136+
137+
agentConnection.sendSpans(spans, err => {
138+
expect(err.message).to.match(/Request payload is too large/);
139+
done();
140+
});
141+
});
142+
143+
it('should throw error if size of payload exceeds maxContentLength for profiles', done => {
144+
const bigData = 'a'.repeat(1024 * 1024 * 21);
145+
const profiles = { profile: bigData };
146+
147+
agentConnection.sendProfiles(profiles, err => {
148+
expect(err.message).to.match(/Request payload is too large/);
149+
done();
150+
});
151+
});
122152
});

0 commit comments

Comments
 (0)