Skip to content

Commit 089e8e1

Browse files
authored
fix(agent): improve fetchAgentInfo error handling (#7313)
Don't call the callback provided to fetchAgentInfo twice if it throws
1 parent 7b864e2 commit 089e8e1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/dd-trace/src/agent/info.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ function fetchAgentInfo (url, callback) {
3636
if (err) {
3737
return callback(err)
3838
}
39+
3940
try {
40-
const response = JSON.parse(res)
41-
cachedUrl = urlKey
42-
cachedData = response
43-
cachedTimestamp = Date.now()
44-
return callback(null, response)
41+
cachedData = JSON.parse(res)
4542
} catch (e) {
4643
return callback(e)
4744
}
45+
46+
cachedUrl = urlKey
47+
cachedTimestamp = Date.now()
48+
49+
callback(null, cachedData)
4850
})
4951
}
5052

0 commit comments

Comments
 (0)