@@ -182,14 +182,14 @@ async function main() {
182
182
if ( ! token ) {
183
183
httpRequestsWithoutToken . inc ( ) ;
184
184
activeSpan ?. recordException ( 'Missing token in request' ) ;
185
- void res . status ( 401 ) . send ( 'Missing token' ) ;
185
+ await res . status ( 401 ) . send ( 'Missing token' ) ;
186
186
return ;
187
187
}
188
188
189
189
if ( token . length !== 32 ) {
190
190
activeSpan ?. recordException ( 'Invalid token' ) ;
191
191
httpRequestsWithoutToken . inc ( ) ;
192
- void res . status ( 401 ) . send ( 'Invalid token' ) ;
192
+ await res . status ( 401 ) . send ( 'Invalid token' ) ;
193
193
return ;
194
194
}
195
195
@@ -205,7 +205,7 @@ async function main() {
205
205
httpRequestsWithNonExistingToken . inc ( ) ;
206
206
req . log . info ( 'Token not found (token=%s)' , maskedToken ) ;
207
207
activeSpan ?. recordException ( 'Token not found' ) ;
208
- void res . status ( 401 ) . send ( 'Missing token' ) ;
208
+ await res . status ( 401 ) . send ( 'Missing token' ) ;
209
209
return ;
210
210
}
211
211
@@ -217,7 +217,7 @@ async function main() {
217
217
httpRequestsWithNoAccess . inc ( ) ;
218
218
req . log . info ( 'No access (token=%s)' , maskedToken ) ;
219
219
activeSpan ?. recordException ( 'No access' ) ;
220
- void res . status ( 403 ) . send ( 'No access' ) ;
220
+ await res . status ( 403 ) . send ( 'No access' ) ;
221
221
return ;
222
222
}
223
223
@@ -259,13 +259,13 @@ async function main() {
259
259
droppedReports
260
260
. labels ( { targetId : tokenInfo . target , orgId : tokenInfo . organization } )
261
261
. inc ( ) ;
262
- authenticatedRequestLogger . info (
262
+ authenticatedRequestLogger . debug (
263
263
'Rate limited' ,
264
264
maskedToken ,
265
265
tokenInfo . target ,
266
266
tokenInfo . organization ,
267
267
) ;
268
- void res . status ( 429 ) . send ( ) ;
268
+ await res . status ( 429 ) . send ( ) ;
269
269
270
270
return ;
271
271
}
@@ -297,7 +297,7 @@ async function main() {
297
297
// 503 - Service Unavailable
298
298
// The server is currently unable to handle the request due being not ready.
299
299
// This tells the gateway to retry the request and not to drop it.
300
- void res . status ( 503 ) . send ( ) ;
300
+ await res . status ( 503 ) . send ( ) ;
301
301
return ;
302
302
}
303
303
@@ -311,11 +311,14 @@ async function main() {
311
311
stopTimer ( {
312
312
status : 'success' ,
313
313
} ) ;
314
- void res . status ( 200 ) . send ( {
314
+ await res . status ( 200 ) . send ( {
315
315
id : result . report . id ,
316
316
operations : result . operations ,
317
317
} ) ;
318
- } else if ( apiVersion === '2' ) {
318
+ return ;
319
+ }
320
+
321
+ if ( apiVersion === '2' ) {
319
322
activeSpan ?. addEvent ( 'using v2' ) ;
320
323
const result = measureParsing (
321
324
( ) => usageProcessorV2 ( server . log , req . body , tokenInfo , retentionInfo ) ,
@@ -336,7 +339,7 @@ async function main() {
336
339
activeSpan ?. recordException ( error . path + ': ' + error . message ) ,
337
340
) ;
338
341
339
- void res . status ( 400 ) . send ( {
342
+ await res . status ( 400 ) . send ( {
340
343
errors : result . errors ,
341
344
} ) ;
342
345
@@ -347,18 +350,20 @@ async function main() {
347
350
stopTimer ( {
348
351
status : 'success' ,
349
352
} ) ;
350
- void res . status ( 200 ) . send ( {
353
+ await res . status ( 200 ) . send ( {
351
354
id : result . report . id ,
352
355
operations : result . operations ,
353
356
} ) ;
354
- } else {
355
- authenticatedRequestLogger . debug ( "Invalid 'x-api-version' header value." ) ;
356
- stopTimer ( {
357
- status : 'error' ,
358
- } ) ;
359
- activeSpan ?. recordException ( "Invalid 'x-api-version' header value." ) ;
360
- void res . status ( 401 ) . send ( "Invalid 'x-api-version' header value." ) ;
357
+ return ;
361
358
}
359
+
360
+ authenticatedRequestLogger . debug ( "Invalid 'x-api-version' header value." ) ;
361
+ stopTimer ( {
362
+ status : 'error' ,
363
+ } ) ;
364
+ activeSpan ?. recordException ( "Invalid 'x-api-version' header value." ) ;
365
+ await res . status ( 401 ) . send ( "Invalid 'x-api-version' header value." ) ;
366
+ return ;
362
367
} catch ( error ) {
363
368
stopTimer ( {
364
369
status : 'error' ,
@@ -369,26 +374,26 @@ async function main() {
369
374
level : 'error' ,
370
375
} ) ;
371
376
activeSpan ?. recordException ( error as Error ) ;
372
- void res . status ( 500 ) . send ( ) ;
377
+ await res . status ( 500 ) . send ( ) ;
373
378
}
374
379
} ) ,
375
380
} ) ;
376
381
377
382
server . route ( {
378
383
method : [ 'GET' , 'HEAD' ] ,
379
384
url : '/_health' ,
380
- handler ( _ , res ) {
381
- void res . status ( 200 ) . send ( ) ;
385
+ async handler ( _ , res ) {
386
+ await res . status ( 200 ) . send ( ) ;
382
387
} ,
383
388
} ) ;
384
389
385
390
server . route ( {
386
391
method : [ 'GET' , 'HEAD' ] ,
387
392
url : '/_readiness' ,
388
- handler ( _ , res ) {
393
+ async handler ( _ , res ) {
389
394
const isReady = readiness ( ) ;
390
395
reportReadiness ( isReady ) ;
391
- void res . status ( isReady ? 200 : 400 ) . send ( ) ;
396
+ await res . status ( isReady ? 200 : 400 ) . send ( ) ;
392
397
} ,
393
398
} ) ;
394
399
0 commit comments