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