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

fix(console): never invoke Proxy traps when logging a Proxy #25063

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

marvinhagemeister
Copy link
Contributor

When doing console.log(someProxy) the Proxy traps should never be invoked. We always did invoke them before which lead to unexpected errors. This aligns proxy logging in Deno with all other runtimes.

Fixes #25054
Fixes #24980
Fixes #12926

Comment on lines -646 to -648
if (proxyDetails !== null && ctx.showProxy) {
return `Proxy ` + formatValue(ctx, proxyDetails, recurseTimes);
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this looks like a lot of changes, but I basically only hoisted out this proxyDetails !== null branch and moved it to a few lines above. So it's only indentation changes from here on.

@@ -2118,30 +2166,6 @@ Deno.test(function inspectProxy() {
)),
`{ key: "value" }`,
);
assertEquals(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this test, because it was asserting that we did invoke proxy traps, even if we shouldn't.

function createFilteredInspectProxy<TObject>(params: {
object: TObject;
keys: (keyof TObject)[];
evaluate: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to remain evaluate option to detect if it's an instance object or a prototype object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants