texasranger
texasranger2y ago

AssertionError: Test case is leaking async ops

- 2 async operations to op_read were started before this test, but were completed during the test. Async operations should not complete in a test if they were not started in that test. | | - 1 async operation to op_spawn_wait was started before this test, but was completed during the test. Async operations should not complete in a test if they were not started in that test. I have sanitizeOps: false, sanitizeResources: false and yet I get this error? I'm 99% sure this is from npm:prisma aka I don't have control over it. I just need to figure out how to get this error to go away or my tests wont pass :/
8 Replies
AapoAlas
AapoAlas2y ago
Note that even if you set sanitizing to false on a sub-step, the top level test will still try to sanitize itself and may complain of this.
texasranger
texasrangerOP2y ago
What do you mean by "top level test" Also, I only get this when running the tests on ubuntu / github actions. i do not get this error on MacOS. On Mac, the tests run just fine.
AapoAlas
AapoAlas2y ago
Deno.test("mytest", async (t) => {
await t.step({
name: "mystep",
sanitizeOps: false,
sanitizeResources: false,
async fn() {
// ...
}
});
});
Deno.test("mytest", async (t) => {
await t.step({
name: "mystep",
sanitizeOps: false,
sanitizeResources: false,
async fn() {
// ...
}
});
});
This sort of case: I know "mystep" leaks ops and resources so I stop it from sanitizing. But, "mytest" will still try to sanitize and it will fail that sanitization if the ops and resources leaked in "mystep" are not cleaned up somehow.
texasranger
texasrangerOP2y ago
I am using BDD, so it would be describe and it, but i believe it would be the same issue as they use test and step underneath right?
AapoAlas
AapoAlas2y ago
Yeah, I think so.
texasranger
texasrangerOP2y ago
OK, I'll try adding sanitizeOps: false, sanitizeResources: false, to describe as well Same issue I think that fixed it for one of the tests, but the others same problem The fact this works fine on MacOS but not inside docker / ubuntu is weird Here is an example of what I am doing:
describe({name: 'API: DB: Auth', sanitizeOps: false, sanitizeResources: false}, () => {
it({name: 'should create a user and org', sanitizeOps: false, sanitizeResources: false}, async () => {
const { org, user } = await createUserAndOrg('...')
})
describe({name: 'API: DB: Auth', sanitizeOps: false, sanitizeResources: false}, () => {
it({name: 'should create a user and org', sanitizeOps: false, sanitizeResources: false}, async () => {
const { org, user } = await createUserAndOrg('...')
})
There is always one top level describe, and then all the it on the inside are the same level I only have two tests, and both trigger the original error posted at the top of the thread It would be handy to have a top level way to say ignore op_read and op_spawn_wait issues
AapoAlas
AapoAlas2y ago
Yeah, that's a bit odd. Of course, it's not too-too odd to have somewhat env dependent behaviour but still. Not really relevant (I hope) but sanitization settings flow downwards, so here the it call shouldn't need them anymore, it will inherit them from the describe. @texas.ranger Hmm, one thing actually might be that you do not seem to be awaiting your it. I think that's necessary. At least with Deno.test() and t.step() all steps must be awaited inside the text() call.
texasranger
texasrangerOP2y ago
I am awaiting I just wrote it out real quick. Thanks for checking on that though. Worth a try Did not make a difference, but good to know you can just set the sanitize params at the very top and not need to do it on each individual test