@reproapp/node-sdk 0.0.44 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -4875,11 +4875,11 @@ function reproMiddleware(cfg) {
|
|
|
4875
4875
|
?? await materializeInlinePrivacyValueAsync('response.body', sanitizeRequestSnapshot(capturedBody), captureCfg, maskReq, endpointTraceCtx, masking, activePrivacy);
|
|
4876
4876
|
const responseBody = responseBodyMaterialization.value;
|
|
4877
4877
|
const requestValueEntries = [];
|
|
4878
|
-
const bodyValueCapture =
|
|
4878
|
+
const bodyValueCapture = requestBodyRaw === undefined
|
|
4879
4879
|
? undefined
|
|
4880
4880
|
: await maybeCaptureRequestValueAsync({
|
|
4881
4881
|
target: 'request.body',
|
|
4882
|
-
rawValue:
|
|
4882
|
+
rawValue: requestBodyRaw,
|
|
4883
4883
|
previewValue: requestBody,
|
|
4884
4884
|
capture: {
|
|
4885
4885
|
runtimeConfig: captureCfg,
|
|
@@ -4929,7 +4929,7 @@ function reproMiddleware(cfg) {
|
|
|
4929
4929
|
privacy: activePrivacy,
|
|
4930
4930
|
},
|
|
4931
4931
|
}, requestValueEntries);
|
|
4932
|
-
const respBodyValueCapture =
|
|
4932
|
+
const respBodyValueCapture = capturedBody === undefined
|
|
4933
4933
|
? undefined
|
|
4934
4934
|
: await maybeCaptureRequestValueAsync({
|
|
4935
4935
|
target: 'response.body',
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6036,11 +6036,11 @@ export function reproMiddleware(cfg: ReproMiddlewareConfig) {
|
|
|
6036
6036
|
);
|
|
6037
6037
|
const responseBody = responseBodyMaterialization.value;
|
|
6038
6038
|
const requestValueEntries: TraceValueBatchEntry[] = [];
|
|
6039
|
-
const bodyValueCapture =
|
|
6039
|
+
const bodyValueCapture = requestBodyRaw === undefined
|
|
6040
6040
|
? undefined
|
|
6041
6041
|
: await maybeCaptureRequestValueAsync({
|
|
6042
6042
|
target: 'request.body',
|
|
6043
|
-
rawValue:
|
|
6043
|
+
rawValue: requestBodyRaw,
|
|
6044
6044
|
previewValue: requestBody,
|
|
6045
6045
|
capture: {
|
|
6046
6046
|
runtimeConfig: captureCfg,
|
|
@@ -6090,7 +6090,7 @@ export function reproMiddleware(cfg: ReproMiddlewareConfig) {
|
|
|
6090
6090
|
privacy: activePrivacy,
|
|
6091
6091
|
},
|
|
6092
6092
|
}, requestValueEntries);
|
|
6093
|
-
const respBodyValueCapture =
|
|
6093
|
+
const respBodyValueCapture = capturedBody === undefined
|
|
6094
6094
|
? undefined
|
|
6095
6095
|
: await maybeCaptureRequestValueAsync({
|
|
6096
6096
|
target: 'response.body',
|
|
@@ -142,6 +142,8 @@ async function main() {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
const large = makeReqRes('S_perf_large_payload', 'A_perf_large_payload', '/large-payload');
|
|
145
|
+
large.req.method = 'POST';
|
|
146
|
+
large.req.body = largePayload();
|
|
145
147
|
await invokeMiddleware(middleware, large.req, large.res, async () => {
|
|
146
148
|
const traced = global.__repro_call(
|
|
147
149
|
largeTraceReturn,
|
|
@@ -160,12 +162,48 @@ async function main() {
|
|
|
160
162
|
|
|
161
163
|
const backendRequest = eventsOf(capturedBodies, 'backend_request')[0]?.payload?.request;
|
|
162
164
|
assert(backendRequest, JSON.stringify(capturedBodies));
|
|
165
|
+
assert.equal(backendRequest.body, undefined, JSON.stringify(backendRequest));
|
|
166
|
+
assert.equal(
|
|
167
|
+
backendRequest.bodyMaterialization?.reason,
|
|
168
|
+
'inline-size-limit',
|
|
169
|
+
JSON.stringify(backendRequest),
|
|
170
|
+
);
|
|
171
|
+
assert.equal(
|
|
172
|
+
backendRequest.bodyValueCapture?.status,
|
|
173
|
+
'stored',
|
|
174
|
+
JSON.stringify(backendRequest),
|
|
175
|
+
);
|
|
163
176
|
assert.equal(backendRequest.respBody, undefined, JSON.stringify(backendRequest));
|
|
164
177
|
assert.equal(
|
|
165
178
|
backendRequest.respBodyMaterialization?.reason,
|
|
166
179
|
'inline-size-limit',
|
|
167
180
|
JSON.stringify(backendRequest),
|
|
168
181
|
);
|
|
182
|
+
assert.equal(
|
|
183
|
+
backendRequest.respBodyValueCapture?.status,
|
|
184
|
+
'stored',
|
|
185
|
+
JSON.stringify(backendRequest),
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const requestValues = eventsOf(capturedBodies, 'backend_request')
|
|
189
|
+
.flatMap((event) => Array.isArray(event?.payload?.requestValues) ? event.payload.requestValues : []);
|
|
190
|
+
const capturedRequestBody = requestValues.find((entry) =>
|
|
191
|
+
entry?.id === backendRequest.bodyValueCapture.valueId &&
|
|
192
|
+
entry?.target === 'request.body'
|
|
193
|
+
);
|
|
194
|
+
const capturedResponseBody = requestValues.find((entry) =>
|
|
195
|
+
entry?.id === backendRequest.respBodyValueCapture.valueId &&
|
|
196
|
+
entry?.target === 'response.body'
|
|
197
|
+
);
|
|
198
|
+
assert(capturedRequestBody, JSON.stringify(requestValues));
|
|
199
|
+
assert(capturedResponseBody, JSON.stringify(requestValues));
|
|
200
|
+
assert.equal(capturedRequestBody.value?.rows?.length, 400, JSON.stringify(capturedRequestBody));
|
|
201
|
+
assert.equal(capturedResponseBody.value?.rows?.length, 400, JSON.stringify(capturedResponseBody));
|
|
202
|
+
assert.equal(
|
|
203
|
+
capturedResponseBody.value.rows[399].depot,
|
|
204
|
+
'depot-399',
|
|
205
|
+
JSON.stringify(capturedResponseBody),
|
|
206
|
+
);
|
|
169
207
|
|
|
170
208
|
const traceEvents = eventsOf(capturedBodies, 'trace_batch')
|
|
171
209
|
.flatMap((event) => Array.isArray(event?.payload?.trace) ? event.payload.trace : []);
|
|
@@ -307,7 +307,7 @@ async function testKafkaTraceFlushIsNotBlockedForeverByActiveHttpRequest() {
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
async function
|
|
310
|
+
async function testLargeHttpResponseBodyKeepsFullValueOutOfBand() {
|
|
311
311
|
const marker = 'OVERSIZED_HTTP_RESPONSE_MARKER';
|
|
312
312
|
const capturedBodies = [];
|
|
313
313
|
const originalFetch = global.fetch;
|
|
@@ -344,13 +344,28 @@ async function testLargeHttpResponseBodyKeepsRequestMetadataWithoutInlineBody()
|
|
|
344
344
|
return text.includes('"event_type":"backend_request"') &&
|
|
345
345
|
text.includes('"reason":"inline-size-limit"');
|
|
346
346
|
}));
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
assert(
|
|
353
|
-
assert(
|
|
347
|
+
const backendEvent = capturedBodies
|
|
348
|
+
.flatMap((body) => Array.isArray(body?.events) ? body.events : [])
|
|
349
|
+
.find((event) => event?.event_type === 'backend_request');
|
|
350
|
+
const request = backendEvent?.payload?.request;
|
|
351
|
+
const requestValues = backendEvent?.payload?.requestValues;
|
|
352
|
+
assert(request, JSON.stringify(capturedBodies));
|
|
353
|
+
assert.strictEqual(request.respBody, undefined, JSON.stringify(request));
|
|
354
|
+
assert.strictEqual(request.respBodyMaterialization?.reason, 'inline-size-limit');
|
|
355
|
+
assert.strictEqual(request.respBodyValueCapture?.status, 'stored');
|
|
356
|
+
assert(!JSON.stringify(request).includes(marker), JSON.stringify(request));
|
|
357
|
+
const capturedResponse = requestValues?.find((entry) =>
|
|
358
|
+
entry?.id === request.respBodyValueCapture.valueId &&
|
|
359
|
+
entry?.target === 'response.body'
|
|
360
|
+
);
|
|
361
|
+
assert(capturedResponse, JSON.stringify(requestValues));
|
|
362
|
+
assert.strictEqual(
|
|
363
|
+
capturedResponse.value?.payload,
|
|
364
|
+
`${marker}:${'x'.repeat(12 * 1024)}`,
|
|
365
|
+
);
|
|
366
|
+
assert(!JSON.stringify(request).includes('__type":"json-string'), JSON.stringify(request));
|
|
367
|
+
assert(!JSON.stringify(request).includes('__truncatedKeys'), JSON.stringify(request));
|
|
368
|
+
assert(!JSON.stringify(request).includes('more chars'), JSON.stringify(request));
|
|
354
369
|
} finally {
|
|
355
370
|
await flushIngestQueue();
|
|
356
371
|
global.fetch = originalFetch;
|
|
@@ -746,7 +761,7 @@ async function main() {
|
|
|
746
761
|
await testKafkaConsumerTraceUsesConsumeTraceId();
|
|
747
762
|
await testKafkaProducerCapturesFullPublishedMessageValue();
|
|
748
763
|
await testKafkaTraceFlushIsNotBlockedForeverByActiveHttpRequest();
|
|
749
|
-
await
|
|
764
|
+
await testLargeHttpResponseBodyKeepsFullValueOutOfBand();
|
|
750
765
|
await testJsonBuiltinTracePayloadsAreOmitted();
|
|
751
766
|
await testLargeStringTraceValuesStayIngestibleAndCaptureFullValueOutOfBand();
|
|
752
767
|
await testLargeStructuredTraceValuesStayIngestibleAndCaptureFullValueOutOfBand();
|