Skip to content

Commit 295edf4

Browse files
authored
Test sample context propagation through promises too (#5740)
1 parent 0672b4d commit 295edf4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

integration-tests/profiler/codehotspots.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function runBusySpans () {
3434
for (let i = 0; i < 3; ++i) {
3535
const z = i
3636
tracer.trace('y' + i, (_, done2) => {
37-
setTimeout(() => {
37+
const busyWork = () => {
3838
busyLoop()
3939
done2()
4040
if (z === 2) {
@@ -43,7 +43,17 @@ function runBusySpans () {
4343
}
4444
done()
4545
}
46-
}, 0)
46+
}
47+
if (i === 1) {
48+
// Exercise sample context propagation through a promise
49+
const p = new Promise((resolve) => {
50+
setTimeout(resolve, 0)
51+
})
52+
p.then(busyWork)
53+
} else {
54+
// Exercise sample context propagation through a timeout
55+
setTimeout(busyWork, 0)
56+
}
4757
})
4858
}
4959
})

0 commit comments

Comments
 (0)