Skip to content

Commit

Permalink
fix: Do not DoS agent with huge payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Apr 12, 2020
1 parent 7d3329b commit 7886130
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/cubejs-server-core/core/agentCollect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fetch = require('node-fetch');
const crypto = require('crypto');

let flushPromise = null;
let trackEvents = [];
const trackEvents = [];

module.exports = async (event, endpointUrl, logger) => {
trackEvents.push({
Expand All @@ -12,8 +12,7 @@ module.exports = async (event, endpointUrl, logger) => {
});
const flush = async (toFlush, retries) => {
if (!toFlush) {
toFlush = trackEvents;
trackEvents = [];
toFlush = trackEvents.splice(0, 20);
}
if (!toFlush.length) {
return null;
Expand Down

0 comments on commit 7886130

Please sign in to comment.