Skip to content

Commit d4fb77c

Browse files
authored
fix: increase batch payload size limit from 32KB (#110)
1 parent 76789be commit d4fb77c

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

lib/Consumer/ForkCurl.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ public function flushBatch($messages)
7474

7575
$cmd .= " '" . $url . "'";
7676

77-
// Verify message size is below than 32KB
78-
if (strlen($payload) >= 32 * 1024) {
77+
if (strlen($payload) >= self::MAX_BATCH_PAYLOAD_SIZE) {
7978
if ($this->debug()) {
80-
$msg = "Message size is larger than 32KB";
79+
$msg = "Message size is larger than " . self::MAX_BATCH_PAYLOAD_SIZE_HUMAN;
8180
error_log("[PostHog][" . $this->type . "] " . $msg);
8281
}
8382

lib/Consumer/LibCurl.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ public function flushBatch($messages)
5656
$body = $this->payload($messages);
5757
$payload = json_encode($body);
5858

59-
// Verify message size is below than 32KB
60-
if (strlen($payload) >= 32 * 1024) {
59+
if (strlen($payload) >= self::MAX_BATCH_PAYLOAD_SIZE) {
6160
if ($this->debug()) {
62-
$msg = "Message size is larger than 32KB";
61+
$msg = "Message size is larger than " . self::MAX_BATCH_PAYLOAD_SIZE_HUMAN;
6362
error_log("[PostHog][" . $this->type . "] " . $msg);
6463
}
6564

lib/Consumer/Socket.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ private function createBody($host, $content)
200200
$req .= "\r\n";
201201
$req .= $content;
202202

203-
// Verify message size is below than 32KB
204-
if (strlen($req) >= 32 * 1024) {
203+
if (strlen($req) >= self::MAX_BATCH_PAYLOAD_SIZE) {
205204
if ($this->debug()) {
206-
$msg = "Message size is larger than 32KB";
205+
$msg = "Message size is larger than " . self::MAX_BATCH_PAYLOAD_SIZE_HUMAN;
207206
error_log("[PostHog][" . $this->type . "] " . $msg);
208207
}
209208

lib/QueueConsumer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
abstract class QueueConsumer extends Consumer
66
{
7+
protected const MAX_BATCH_PAYLOAD_SIZE = 1024 * 1024; // 1MB
8+
protected const MAX_BATCH_PAYLOAD_SIZE_HUMAN = (self::MAX_BATCH_PAYLOAD_SIZE / 1024) . 'KB';
9+
710
protected $type = "QueueConsumer";
811

912
protected $queue;

0 commit comments

Comments
 (0)