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

feat(test): improved op sanitizer errors + traces #13676

Merged
merged 7 commits into from
Feb 16, 2022

Conversation

lucacasonato
Copy link
Member

This commit improves the error messages for the deno test async op
sanitizer. It does this in two ways:

  • it uses handwritten error messages for each op that could be leaking
  • it includes traces showing where each op was started

This "async op tracing" functionality is a new feature in deno_core.
It likely has a significant performance impact, which is why it is only
enabled in tests.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This should help out users a lot.

core/01_core.js Show resolved Hide resolved
runtime/js/40_testing.js Show resolved Hide resolved
runtime/js/40_testing.js Outdated Show resolved Hide resolved
* To get high level metrics on async ops with no added performance cost,
* use `Deno.core.metrics()`.
*/
function enableOpCallTracing(): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just have a boolean value that can be assigned, rather than a function:

Deno.core.enableOpCallTracing = true;

This allows for future flexibility (if you want to turn it off) and less wrapper.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chosen approach is actually intentional: the "enabled" flag is a boolean (a primitive), so assigning it to Deno.core assigns it by value, not by reference. To fix this, we'd need to change the check in opAsync to be if (core.opCallTracingEnabled) instead of if (opCallTracingEnabled). The former introduces an additional property lookup to all opAsync calls which I don't really want as it is a super hot path.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - seems like it will really help people understand their programs!

@lucacasonato lucacasonato force-pushed the improved_resource_test branch 2 times, most recently from b515bcb to 1cb2ec9 Compare February 16, 2022 15:52
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work

This commit improves the error messages for the `deno test` async op
sanitizer. It does this in two ways:
- it uses handwritten error messages for each op that could be leaking
- it includes traces showing where each op was started

This "async op tracing" functionality is a new feature in deno_core.
It likely has a significant performance impact, which is why it is only
enabled in tests.
@lucacasonato lucacasonato merged commit 53088e1 into denoland:main Feb 16, 2022
@lucacasonato lucacasonato deleted the improved_resource_test branch February 16, 2022 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants