Skip to content

Commit 2323493

Browse files
committed
add safety fallbacks
1 parent d5b2b77 commit 2323493

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/node/src/integrations/http/SentryHttpInstrumentation.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope):
433433
* Convert a HTTP request object to RequestEventData to be passed as normalizedRequest.
434434
*/
435435
export function httpRequestToRequestEventData(request: IncomingMessage): RequestEventData {
436-
const headers = request.headers;
436+
const headers = request.headers || {};
437437
const host = headers.host || '<no host>';
438438
const protocol = request.socket && (request.socket as { encrypted?: boolean }).encrypted ? 'https' : 'http';
439439
const originalUrl = request.url || '';
@@ -446,7 +446,7 @@ export function httpRequestToRequestEventData(request: IncomingMessage): Request
446446
url: absoluteUrl,
447447
method: request.method,
448448
query_string: extractQueryParamsFromUrl(originalUrl),
449-
headers: headersToDict(request.headers),
449+
headers: headersToDict(headers),
450450
cookies,
451451
};
452452

0 commit comments

Comments
 (0)