Skip to content

Commit dcf3b05

Browse files
committed
Adjust cache timings
1 parent e089442 commit dcf3b05

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/dd-trace/src/debugger/devtools_client/source-maps.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ function setCacheTTL () {
5252

5353
cacheTimer = setTimeout(function () {
5454
cacheTimer = null
55-
if (Date.now() - cacheTime < 1_000) {
56-
// If the last cache entry was added less then 1s ago, keep the cache alive
55+
if (Date.now() - cacheTime < 2_500) {
56+
// If the last cache entry was added recently, keep the cache alive
5757
setCacheTTL()
5858
} else {
5959
// Optimize for app boot, where a lot of reads might happen
6060
// Clear cache a few seconds after it was last used
6161
cache.clear()
6262
}
63-
}, 10_000).unref()
63+
}, 5_000).unref()
6464
}
6565

6666
function loadInlineSourceMap (data) {

packages/dd-trace/test/debugger/devtools_client/source-maps.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ describe('source map utils', function () {
188188
expect(readFile.callCount).to.equal(1)
189189
})
190190

191-
it('should clear cache after 10 seconds', async function () {
192-
clock.tick(10_000)
191+
it('should clear cache after 5 seconds', async function () {
192+
clock.tick(5_000)
193193
const sourceMap = await loadSourceMap(dir, sourceMapURL)
194194
expect(sourceMap).to.deep.equal(parsedSourceMap)
195195
expect(readFile.callCount).to.equal(2)
@@ -213,8 +213,8 @@ describe('source map utils', function () {
213213
expect(readFileSync.callCount).to.equal(1)
214214
})
215215

216-
it('should clear cache after 10 seconds', function () {
217-
clock.tick(10_000)
216+
it('should clear cache after 5 seconds', function () {
217+
clock.tick(5_000)
218218
const sourceMap = loadSourceMapSync(dir, sourceMapURL)
219219
expect(sourceMap).to.deep.equal(parsedSourceMap)
220220
expect(readFileSync.callCount).to.equal(2)

0 commit comments

Comments
 (0)