Skip to content

Commit fd7b975

Browse files
committed
Change the default value for keepalive to false (#1359)
1 parent 767b485 commit fd7b975

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

libraries/tracker-core/src/emitter/emitter_request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function newEmitterRequest({
8888
eventMethod = 'post',
8989
customHeaders,
9090
connectionTimeout,
91-
keepalive = true,
91+
keepalive = false,
9292
postPath = '/com.snowplowanalytics.snowplow/tp2',
9393
useStm = true,
9494
maxPostBytes = 40000,

libraries/tracker-core/src/emitter/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export interface EmitterConfigurationBase {
116116
/**
117117
* Indicates that the request should be allowed to outlive the webpage that initiated it.
118118
* Enables collector requests to complete even if the page is closed or navigated away from.
119-
* @defaultValue true (not supported in Node.js)
119+
* Note: Browsers put a limit on keepalive requests of 64KB. In case of multiple keepalive requests in parallel (may happen in case of multiple trackers), the limit is shared.
120+
* @defaultValue false
120121
*/
121122
keepalive?: boolean;
122123
/**

libraries/tracker-core/test/emitter/emitter_request.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ test('toRequest returns a Request object with default settings', (t) => {
133133
t.is(req.method, 'POST');
134134
t.is(req.headers.get('Content-Type'), 'application/json; charset=UTF-8');
135135
t.is(req.headers.get('SP-Anonymous'), null);
136-
t.is(req.keepalive, true);
137136
});
138137

139138
test('toRequest builds a GET request when method is get', (t) => {
@@ -194,12 +193,12 @@ test('toRequest includes server anonymization header', (t) => {
194193
test('toRequest contains keepalive', (t) => {
195194
const request = newEmitterRequest({
196195
endpoint: 'https://example.com',
197-
keepalive: false,
196+
keepalive: true,
198197
});
199198

200199
t.true(request.addEvent(newEmitterEventFromPayload({ e: 'pv', p: 'web' })));
201200
const req = request.toRequest()!;
202-
t.is(req.keepalive, false);
201+
t.is(req.keepalive, true);
203202
});
204203

205204
test('toRequest URL contains custom POST path', (t) => {

0 commit comments

Comments
 (0)