diff options
author | Luca Casonato <hello@lcas.dev> | 2023-09-14 16:38:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-14 16:38:15 +0200 |
commit | 851f795001a9164572d02606587ddc5193bdfd2d (patch) | |
tree | 77a129ff766013dd9ea0cb83d6a84a40e4f1f0f7 /cli/js | |
parent | bbb348aa33b56e15f376e8e7ee7b71bd5badd936 (diff) |
fix: output traces for op sanitizer in more cases (#20494)
This adds traces for the "started outside test, closed inside test"
case.
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/40_testing.js | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index 37eb6be8f..443b91596 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -206,15 +206,30 @@ function assertOps(fn) { } else if (dispatchedDiff < completedDiff) { const [name, hint] = OP_DETAILS[key] || [key, null]; const count = completedDiff - dispatchedDiff; - ArrayPrototypePush( - details, - `${count} async operation${count === 1 ? "" : "s"} to ${name} ${ - count === 1 ? "was" : "were" - } started before this test, but ${ - count === 1 ? "was" : "were" - } completed during the test. Async operations should not complete in a test if they were not started in that test. - ${hint ? `This is often caused by not ${hint}.` : ""}`, - ); + let message = `${count} async operation${ + count === 1 ? "" : "s" + } to ${name} ${ + count === 1 ? "was" : "were" + } started before this test, but ${ + count === 1 ? "was" : "were" + } completed during the test. Async operations should not complete in a test if they were not started in that test.`; + if (hint) { + message += ` This is often caused by not ${hint}.`; + } + const traces = []; + for (const [id, { opName, stack }] of preTraces) { + if (opName !== key) continue; + if (MapPrototypeHas(postTraces, id)) continue; + ArrayPrototypePush(traces, stack); + } + if (traces.length === 1) { + message += " The operation was started here:\n"; + message += traces[0]; + } else if (traces.length > 1) { + message += " The operations were started here:\n"; + message += ArrayPrototypeJoin(traces, "\n\n"); + } + ArrayPrototypePush(details, message); } } return { failed: { leakedOps: [details, core.isOpCallTracingEnabled()] } }; |