File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
detectors/node/opentelemetry-resource-detector-aws Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ class AwsEc2Detector implements Detector {
131
131
const timeoutId = setTimeout ( ( ) => {
132
132
req . abort ( ) ;
133
133
reject ( new Error ( 'EC2 metadata api request timed out.' ) ) ;
134
- } , 1000 ) ;
134
+ } , this . MILLISECOND_TIME_OUT ) ;
135
135
136
136
const req = http . request ( options , res => {
137
137
clearTimeout ( timeoutId ) ;
Original file line number Diff line number Diff line change @@ -109,7 +109,8 @@ describe('awsEc2Detector', () => {
109
109
scope . done ( ) ;
110
110
} ) ;
111
111
112
- it ( 'should throw when timed out' , async ( ) => {
112
+ it ( 'should throw when timed out' , function ( done ) {
113
+ this . timeout ( 6000 ) ;
113
114
const expectedError = new Error ( 'EC2 metadata api request timed out.' ) ;
114
115
const scope = nock ( AWS_HOST )
115
116
. put ( AWS_TOKEN_PATH )
@@ -120,17 +121,21 @@ describe('awsEc2Detector', () => {
120
121
. reply ( 200 , ( ) => mockedIdentityResponse )
121
122
. get ( AWS_HOST_PATH )
122
123
. matchHeader ( AWS_METADATA_TOKEN_HEADER , mockedTokenResponse )
123
- . delayConnection ( 2000 )
124
+ . delayConnection ( 5000 )
124
125
. reply ( 200 , ( ) => mockedHostResponse ) ;
125
126
126
- try {
127
- await awsEc2Detector . detect ( ) ;
128
- assert . ok ( false , 'Expected to throw' ) ;
129
- } catch ( err ) {
130
- assert . deepStrictEqual ( err , expectedError ) ;
131
- }
132
-
133
- scope . done ( ) ;
127
+ awsEc2Detector
128
+ . detect ( )
129
+ . then ( ( ) => {
130
+ assert . ok ( false , 'Expected to throw' ) ;
131
+ } )
132
+ . catch ( err => {
133
+ assert . deepStrictEqual ( err , expectedError ) ;
134
+ } )
135
+ . finally ( ( ) => {
136
+ scope . done ( ) ;
137
+ done ( ) ;
138
+ } ) ;
134
139
} ) ;
135
140
136
141
it ( 'should throw when replied with an Error' , async ( ) => {
You can’t perform that action at this time.
0 commit comments