@@ -3,7 +3,7 @@ import { EventEnvelope, EventItem } from '@sentry/types';
3
3
import { createEnvelope , serializeEnvelope } from '@sentry/utils' ;
4
4
import * as http from 'http' ;
5
5
6
- import { makeNewHttpTransport } from '../../../src/transports/new' ;
6
+ import { makeNodeTransport } from '../../../src/transports/new' ;
7
7
8
8
jest . mock ( '@sentry/core' , ( ) => {
9
9
const actualCore = jest . requireActual ( '@sentry/core' ) ;
@@ -48,16 +48,19 @@ function setupTestServer(
48
48
49
49
res . writeHead ( options . statusCode , options . responseHeaders ) ;
50
50
res . end ( ) ;
51
+
52
+ // also terminate socket because keepalive hangs connection a bit
53
+ res . connection . end ( ) ;
51
54
} ) ;
52
55
53
- testServer . listen ( 8099 ) ;
56
+ testServer . listen ( 18099 ) ;
54
57
55
58
return new Promise ( resolve => {
56
59
testServer ?. on ( 'listening' , resolve ) ;
57
60
} ) ;
58
61
}
59
62
60
- const TEST_SERVER_URL = 'http://localhost:8099 ' ;
63
+ const TEST_SERVER_URL = 'http://localhost:18099 ' ;
61
64
62
65
const EVENT_ENVELOPE = createEnvelope < EventEnvelope > ( { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' , sent_at : '123' } , [
63
66
[ { type : 'event' } , { event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' } ] as EventItem ,
@@ -78,7 +81,7 @@ describe('makeNewHttpTransport()', () => {
78
81
it ( 'should correctly return successful server response' , async ( ) => {
79
82
await setupTestServer ( { statusCode : SUCCESS } ) ;
80
83
81
- const transport = makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
84
+ const transport = makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
82
85
const transportResponse = await transport . send ( EVENT_ENVELOPE ) ;
83
86
84
87
expect ( transportResponse ) . toEqual ( expect . objectContaining ( { status : 'success' } ) ) ;
@@ -90,7 +93,7 @@ describe('makeNewHttpTransport()', () => {
90
93
expect ( body ) . toBe ( SERIALIZED_EVENT_ENVELOPE ) ;
91
94
} ) ;
92
95
93
- const transport = makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
96
+ const transport = makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
94
97
await transport . send ( EVENT_ENVELOPE ) ;
95
98
} ) ;
96
99
@@ -105,7 +108,7 @@ describe('makeNewHttpTransport()', () => {
105
108
) ;
106
109
} ) ;
107
110
108
- const transport = makeNewHttpTransport ( {
111
+ const transport = makeNodeTransport ( {
109
112
url : TEST_SERVER_URL ,
110
113
headers : {
111
114
'X-Some-Custom-Header-1' : 'value1' ,
@@ -123,7 +126,7 @@ describe('makeNewHttpTransport()', () => {
123
126
] ) ( 'should correctly reject bad server response (status %i)' , async ( serverStatusCode , expectedStatus ) => {
124
127
await setupTestServer ( { statusCode : serverStatusCode } ) ;
125
128
126
- const transport = makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
129
+ const transport = makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
127
130
await expect ( transport . send ( EVENT_ENVELOPE ) ) . rejects . toEqual ( expect . objectContaining ( { status : expectedStatus } ) ) ;
128
131
} ) ;
129
132
@@ -136,7 +139,7 @@ describe('makeNewHttpTransport()', () => {
136
139
} ,
137
140
} ) ;
138
141
139
- const transport = makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
142
+ const transport = makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
140
143
const transportResponse = await transport . send ( EVENT_ENVELOPE ) ;
141
144
142
145
expect ( transportResponse ) . toEqual ( expect . objectContaining ( { status : 'success' } ) ) ;
@@ -151,7 +154,7 @@ describe('makeNewHttpTransport()', () => {
151
154
} ,
152
155
} ) ;
153
156
154
- const transport = makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
157
+ const transport = makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
155
158
const transportResponse = await transport . send ( EVENT_ENVELOPE ) ;
156
159
157
160
expect ( transportResponse ) . toEqual ( expect . objectContaining ( { status : 'success' } ) ) ;
@@ -160,7 +163,7 @@ describe('makeNewHttpTransport()', () => {
160
163
161
164
describe ( 'proxy' , ( ) => {
162
165
it ( 'can be configured through option' , ( ) => {
163
- makeNewHttpTransport ( {
166
+ makeNodeTransport ( {
164
167
url :
'http://[email protected] :8989/mysubpath/50622' ,
165
168
proxy : 'http://example.com' ,
166
169
} ) ;
@@ -171,7 +174,7 @@ describe('makeNewHttpTransport()', () => {
171
174
172
175
it ( 'can be configured through env variables option' , ( ) => {
173
176
process . env . http_proxy = 'http://example.com' ;
174
- makeNewHttpTransport ( {
177
+ makeNodeTransport ( {
175
178
url :
'http://[email protected] :8989/mysubpath/50622' ,
176
179
} ) ;
177
180
@@ -182,7 +185,7 @@ describe('makeNewHttpTransport()', () => {
182
185
183
186
it ( 'client options have priority over env variables' , ( ) => {
184
187
process . env . http_proxy = 'http://foo.com' ;
185
- makeNewHttpTransport ( {
188
+ makeNodeTransport ( {
186
189
url :
'http://[email protected] :8989/mysubpath/50622' ,
187
190
proxy : 'http://bar.com' ,
188
191
} ) ;
@@ -194,7 +197,7 @@ describe('makeNewHttpTransport()', () => {
194
197
195
198
it ( 'no_proxy allows for skipping specific hosts' , ( ) => {
196
199
process . env . no_proxy = 'sentry.io' ;
197
- makeNewHttpTransport ( {
200
+ makeNodeTransport ( {
198
201
url :
'http://[email protected] :8989/mysubpath/50622' ,
199
202
proxy : 'http://example.com' ,
200
203
} ) ;
@@ -208,7 +211,7 @@ describe('makeNewHttpTransport()', () => {
208
211
process . env . http_proxy = 'http://example.com:8080' ;
209
212
process . env . no_proxy = 'sentry.io:8989' ;
210
213
211
- makeNewHttpTransport ( {
214
+ makeNodeTransport ( {
212
215
url :
'http://[email protected] :8989/mysubpath/50622' ,
213
216
} ) ;
214
217
@@ -222,7 +225,7 @@ describe('makeNewHttpTransport()', () => {
222
225
process . env . http_proxy = 'http://example.com:8080' ;
223
226
process . env . no_proxy = 'example.com,sentry.io,wat.com:1337' ;
224
227
225
- makeNewHttpTransport ( {
228
+ makeNodeTransport ( {
226
229
url :
'http://[email protected] :8989/mysubpath/50622' ,
227
230
} ) ;
228
231
@@ -242,7 +245,7 @@ describe('makeNewHttpTransport()', () => {
242
245
} ,
243
246
} ) ;
244
247
245
- makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
248
+ makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
246
249
const registeredRequestExecutor = ( createTransport as jest . Mock ) . mock . calls [ 0 ] [ 1 ] ;
247
250
248
251
const executorResult = registeredRequestExecutor ( {
@@ -266,7 +269,7 @@ describe('makeNewHttpTransport()', () => {
266
269
statusCode : SUCCESS ,
267
270
} ) ;
268
271
269
- makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
272
+ makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
270
273
const registeredRequestExecutor = ( createTransport as jest . Mock ) . mock . calls [ 0 ] [ 1 ] ;
271
274
272
275
const executorResult = registeredRequestExecutor ( {
@@ -294,7 +297,7 @@ describe('makeNewHttpTransport()', () => {
294
297
} ,
295
298
} ) ;
296
299
297
- makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
300
+ makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
298
301
const registeredRequestExecutor = ( createTransport as jest . Mock ) . mock . calls [ 0 ] [ 1 ] ;
299
302
300
303
const executorResult = registeredRequestExecutor ( {
@@ -322,7 +325,7 @@ describe('makeNewHttpTransport()', () => {
322
325
} ,
323
326
} ) ;
324
327
325
- makeNewHttpTransport ( { url : TEST_SERVER_URL } ) ;
328
+ makeNodeTransport ( { url : TEST_SERVER_URL } ) ;
326
329
const registeredRequestExecutor = ( createTransport as jest . Mock ) . mock . calls [ 0 ] [ 1 ] ;
327
330
328
331
const executorResult = registeredRequestExecutor ( {
0 commit comments