File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11const { SQSClient, SendMessageCommand } = require ( "@aws-sdk/client-sqs" ) ;
2+ const { FetchHttpHandler } = require ( "@smithy/fetch-http-handler" ) ;
23
34/*
45 * This module handles sending spans to an SQS queue.
@@ -12,9 +13,14 @@ exports.HttpSpansAgent = (() => {
1213 let sqsClient ;
1314
1415 const initAgent = ( ) => {
15- sqsClient = new SQSClient ( {
16- region : process . env . AUTO_TRACE_QUEUE_REGION || "eu-west-1" ,
17- } ) ;
16+ try {
17+ sqsClient = new SQSClient ( {
18+ region : process . env . AUTO_TRACE_QUEUE_REGION || "eu-west-1" ,
19+ requestHandler : new FetchHttpHandler ( { } ) ,
20+ } ) ;
21+ } catch ( error ) {
22+ console . warn ( "Error initializing SQS client:" , error ) ;
23+ }
1824 } ;
1925
2026 const cleanSessionInstance = ( ) => {
@@ -37,6 +43,19 @@ exports.HttpSpansAgent = (() => {
3743 } ,
3844 MessageBody : JSON . stringify ( requestBody ) ,
3945 } ) ;
46+
47+ // This is a workaround to avoid the fetch function being overridden
48+ // @ts -ignore
49+ if ( fetch && fetch . __originalFetch ) {
50+ const wrappedFetch = fetch ;
51+ // @ts -ignore
52+ fetch = wrappedFetch . __originalFetch ;
53+ setTimeout ( ( ) => {
54+ // @ts -ignore
55+ fetch = wrappedFetch ;
56+ } , 1 ) ;
57+ }
58+
4059 await sqsClient . send ( command ) ;
4160 } catch ( error ) {
4261 console . warn ( "Error sending trace spans:" , error ) ;
Original file line number Diff line number Diff line change 2020 "dependencies" : {
2121 "@aws-sdk/client-sqs" : " ^3.777.0" ,
2222 "@lumigo/tracer" : " ^1.107.1" ,
23+ "@smithy/fetch-http-handler" : " ^5.0.2" ,
2324 "axios" : " ^1.8.4" ,
2425 "node-fetch" : " ^3.3.2"
2526 },
Original file line number Diff line number Diff line change @@ -9520,6 +9520,7 @@ __metadata:
95209520 dependencies:
95219521 "@aws-sdk/client-sqs": "npm:^3.777.0"
95229522 "@lumigo/tracer": "npm:^1.107.1"
9523+ "@smithy/fetch-http-handler": "npm:^5.0.2"
95239524 "@types/jest": "npm:^29.5.14"
95249525 axios: "npm:^1.8.4"
95259526 esbuild: "npm:^0.25.1"
You can’t perform that action at this time.
0 commit comments