@jaypie/express 1.2.12 → 1.2.14
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/cjs/index.cjs +39 -49
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +39 -49
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -55,18 +55,21 @@ class LambdaRequest extends node_stream.Readable {
|
|
|
55
55
|
remoteAddress: options.remoteAddress,
|
|
56
56
|
};
|
|
57
57
|
this.connection = this.socket;
|
|
58
|
-
// Schedule body push for next tick to ensure stream is ready
|
|
59
|
-
// This is needed for body parsers that consume the stream
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
// Schedule body push for next tick to ensure stream is ready.
|
|
59
|
+
// This is needed for body parsers that consume the stream.
|
|
60
|
+
// CRITICAL: Always schedule the push, even for empty bodies, to ensure
|
|
61
|
+
// the stream emits 'end'. Otherwise, middleware that waits for the request
|
|
62
|
+
// stream to end (like body parsers) will hang forever on GET requests.
|
|
63
|
+
process.nextTick(() => {
|
|
64
|
+
if (!this.bodyPushed) {
|
|
65
|
+
if (this.bodyBuffer && this.bodyBuffer.length > 0) {
|
|
63
66
|
this.push(this.bodyBuffer);
|
|
64
|
-
this.push(null);
|
|
65
|
-
this.bodyPushed = true;
|
|
66
|
-
this.complete = true;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
this.push(null); // Signal end of stream
|
|
69
|
+
this.bodyPushed = true;
|
|
70
|
+
this.complete = true;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
70
73
|
}
|
|
71
74
|
//
|
|
72
75
|
// Readable stream implementation
|
|
@@ -1389,71 +1392,61 @@ function getCurrentInvokeUuid(req) {
|
|
|
1389
1392
|
return getJaypieAdapterUuid();
|
|
1390
1393
|
}
|
|
1391
1394
|
|
|
1392
|
-
//
|
|
1393
|
-
//
|
|
1394
|
-
// Helpers
|
|
1395
|
-
//
|
|
1396
1395
|
/**
|
|
1397
|
-
* Safely
|
|
1396
|
+
* Safely set a header value on response.
|
|
1398
1397
|
* Handles both Express Response and Lambda adapter responses.
|
|
1399
1398
|
* Defensive against dd-trace instrumentation issues.
|
|
1400
1399
|
*/
|
|
1401
|
-
function
|
|
1400
|
+
function safeSetHeader(res, name, value) {
|
|
1402
1401
|
try {
|
|
1403
1402
|
// Try internal method first (completely bypasses dd-trace)
|
|
1404
|
-
if (typeof res.
|
|
1405
|
-
|
|
1403
|
+
if (typeof res._internalSetHeader === "function") {
|
|
1404
|
+
res._internalSetHeader(name, value);
|
|
1405
|
+
return;
|
|
1406
1406
|
}
|
|
1407
1407
|
// Fall back to _headers Map access (Lambda adapter, avoids dd-trace)
|
|
1408
1408
|
if (res._headers instanceof Map) {
|
|
1409
|
-
|
|
1410
|
-
return
|
|
1409
|
+
res._headers.set(name.toLowerCase(), value);
|
|
1410
|
+
return;
|
|
1411
1411
|
}
|
|
1412
|
-
// Fall back to
|
|
1413
|
-
if (typeof res.
|
|
1414
|
-
|
|
1415
|
-
return
|
|
1412
|
+
// Fall back to setHeader (more standard than set)
|
|
1413
|
+
if (typeof res.setHeader === "function") {
|
|
1414
|
+
res.setHeader(name, value);
|
|
1415
|
+
return;
|
|
1416
1416
|
}
|
|
1417
|
-
// Last resort: try
|
|
1418
|
-
if (typeof res.
|
|
1419
|
-
|
|
1420
|
-
return value ? String(value) : undefined;
|
|
1417
|
+
// Last resort: try set
|
|
1418
|
+
if (typeof res.set === "function") {
|
|
1419
|
+
res.set(name, value);
|
|
1421
1420
|
}
|
|
1422
1421
|
}
|
|
1423
1422
|
catch {
|
|
1424
|
-
// Silently fail -
|
|
1423
|
+
// Silently fail - header just won't be set
|
|
1425
1424
|
}
|
|
1426
|
-
return undefined;
|
|
1427
1425
|
}
|
|
1428
1426
|
/**
|
|
1429
|
-
* Safely
|
|
1427
|
+
* Safely remove a header from response.
|
|
1430
1428
|
* Handles both Express Response and Lambda adapter responses.
|
|
1431
1429
|
* Defensive against dd-trace instrumentation issues.
|
|
1432
1430
|
*/
|
|
1433
|
-
function
|
|
1431
|
+
function safeRemoveHeader(res, name) {
|
|
1434
1432
|
try {
|
|
1435
1433
|
// Try internal method first (completely bypasses dd-trace)
|
|
1436
|
-
if (typeof res.
|
|
1437
|
-
res.
|
|
1434
|
+
if (typeof res._internalRemoveHeader === "function") {
|
|
1435
|
+
res._internalRemoveHeader(name);
|
|
1438
1436
|
return;
|
|
1439
1437
|
}
|
|
1440
1438
|
// Fall back to _headers Map access (Lambda adapter, avoids dd-trace)
|
|
1441
1439
|
if (res._headers instanceof Map) {
|
|
1442
|
-
res._headers.
|
|
1440
|
+
res._headers.delete(name.toLowerCase());
|
|
1443
1441
|
return;
|
|
1444
1442
|
}
|
|
1445
|
-
// Fall back to
|
|
1446
|
-
if (typeof res.
|
|
1447
|
-
res.
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
// Last resort: try set
|
|
1451
|
-
if (typeof res.set === "function") {
|
|
1452
|
-
res.set(name, value);
|
|
1443
|
+
// Fall back to removeHeader (standard Node.js http.ServerResponse)
|
|
1444
|
+
if (typeof res.removeHeader === "function") {
|
|
1445
|
+
res.removeHeader(name);
|
|
1453
1446
|
}
|
|
1454
1447
|
}
|
|
1455
1448
|
catch {
|
|
1456
|
-
// Silently fail - header just won't be
|
|
1449
|
+
// Silently fail - header just won't be removed
|
|
1457
1450
|
}
|
|
1458
1451
|
}
|
|
1459
1452
|
//
|
|
@@ -1478,11 +1471,8 @@ const decorateResponse = (res, { handler = "", version = process.env.PROJECT_VER
|
|
|
1478
1471
|
//
|
|
1479
1472
|
// Decorate Headers
|
|
1480
1473
|
//
|
|
1481
|
-
// X-Powered-By
|
|
1482
|
-
|
|
1483
|
-
if (!currentPoweredBy || currentPoweredBy === "Express") {
|
|
1484
|
-
safeSetHeader(extRes, kit.HTTP.HEADER.POWERED_BY, kit.JAYPIE.LIB.EXPRESS);
|
|
1485
|
-
}
|
|
1474
|
+
// Remove X-Powered-By
|
|
1475
|
+
safeRemoveHeader(extRes, kit.HTTP.HEADER.POWERED_BY);
|
|
1486
1476
|
// X-Project-Environment
|
|
1487
1477
|
if (process.env.PROJECT_ENV) {
|
|
1488
1478
|
safeSetHeader(extRes, kit.HTTP.HEADER.PROJECT.ENVIRONMENT, process.env.PROJECT_ENV);
|