Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/HttpClient/middlewares/inflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
// cancel any request
ctx.config.cancelToken = undefined

if (!metricsAdded) {
// global.metrics is only initialized by startApp() in the IO service
// runtime. Standalone consumers of HttpClient (e.g. the toolbelt CLI)
// run without it, so guard the bare global reference.
if (!metricsAdded && typeof metrics !== 'undefined') {
metrics.addOnFlushMetric(() => ({
name: 'node-vtex-api-inflight-map-size',
size: inflight.entries.length,
size: inflight.size,
}))
metricsAdded = true
}
Expand All @@ -32,9 +35,9 @@
const memoized = await inflight.get(key)!
ctx.inflightHit = isInflight
ctx.response = memoized.response
return

Check notice on line 38 in src/HttpClient/middlewares/inflight.ts

View check run for this annotation

Sonar - Workflows / SonarQube Code Analysis

src/HttpClient/middlewares/inflight.ts#L38

Remove this redundant jump.
} else {
const promise = new Promise<Inflight>(async (resolve, reject) => {

Check warning on line 40 in src/HttpClient/middlewares/inflight.ts

View check run for this annotation

Sonar - Workflows / SonarQube Code Analysis

src/HttpClient/middlewares/inflight.ts#L40

Promise executor functions should not be async.
try {
await next()
resolve({
Expand Down
Loading