Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure in test asyncOpsSanitizer when no hint is available for op #13729

Closed
KyleJune opened this issue Feb 20, 2022 · 4 comments · Fixed by #14074
Closed

Failure in test asyncOpsSanitizer when no hint is available for op #13729

KyleJune opened this issue Feb 20, 2022 · 4 comments · Fixed by #14074
Assignees
Labels
bug Something isn't working correctly testing related to deno test and coverage

Comments

@KyleJune
Copy link
Contributor

I don't have a clear reproduction path for this issue but I dug into the 40_testing.js code and I believe I found the cause of the issue. A user of my test_suite module opened an issue saying they were getting an error when upgrading to the newest version that uses the test step API. The user reported they are using Deno 1.19. Looking at the error message, it appeared to actually be an issue with Deno's test runner.

The Deno.metrics().ops object has 281 keys. The OP_DETAILS object in 40_testing.js only has 67 of those keys.

In the asyncOpSanitizer, if there is a difference in ops dispatched and completed, it will try getting hint information from the OP_DETAILS here using destructuring assignment (shown below). If there isn't a hint in OP_DETAILS for the key, then the value returned from OP_DETAILS[key] is going to return undefined and you can't destructure undefined.

const [name, hint] = OP_DETAILS[key];

If the key happens to be one that is undefined, this will throw the following error.

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
        at asyncOpSanitizer (deno:runtime/js/40_testing.js:176:32)
@okcoker
Copy link

okcoker commented Feb 21, 2022

This might be related (or the exact issue reported by OP) but in order to debug I've been using the following function to log before and after certain calls when I can't figure out where the open op is coming from:

function getOpenOps() {
    const metrics = Deno.metrics();

    return {
        ...metrics,
        ops: Object.keys(metrics.ops).reduce((acc: any, key: string) => {
            const op = metrics.ops[key];

            if (!op) {
                console.log('Missing op for key', key);
            }

            if (op && op.opsCompleted !== op.opsDispatched) {
                acc[key] = op;
            }
            return acc;
        }, {}),
    };
}

I noticed I had to check using !op because certain keys didn't have metrics associated with them. In my case I noticed these logs:

Missing op for key op_emit
Missing op for key op_pledge_test_permissions
Missing op for key op_restore_test_permissions
Missing op for key op_get_test_origin
Missing op for key op_dispatch_test_event

@bartlomieju bartlomieju added node compat testing related to deno test and coverage bug Something isn't working correctly and removed node compat labels Feb 21, 2022
@lucacasonato lucacasonato self-assigned this Feb 21, 2022
@lucacasonato
Copy link
Member

Whoops, I know the root cause for this. My bad. I'll fix it soon.

@authcompanion
Copy link

May we have an update, ty vm!

@KyleJune
Copy link
Contributor Author

May we have an update, ty vm!

Discord shows Luca is out of office until March 3rd. I'm guessing it won't be fixed until after that. I'd recommend just downgrading to Deno 1.18 until this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly testing related to deno test and coverage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants