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

Disable log on autocomplete/eager-eval #17

Open
mrjacobbloom opened this issue Mar 3, 2020 · 7 comments
Open

Disable log on autocomplete/eager-eval #17

mrjacobbloom opened this issue Mar 3, 2020 · 7 comments
Labels
bug Something isn't working work in progress A half-baked solution is probably already checked in

Comments

@mrjacobbloom
Copy link
Owner

mrjacobbloom commented Mar 3, 2020

Does Chrome even still eager-eval Echo? What about giving the original (internal) Echo function side effects? It should never be called. Would that prevent autocomplete as well?

Autocomplete seems to stop after a construct (potentially also a call) -- or does it? Maybe there's a way to take advantage of that?

Is it worth it to specialize for Chrome's devtools?

@mrjacobbloom mrjacobbloom added work in progress A half-baked solution is probably already checked in bug Something isn't working labels Mar 3, 2020
@mrjacobbloom
Copy link
Owner Author

mrjacobbloom commented Mar 4, 2020

There's an ownKeys handler: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/ownKeys

Might be able to find a solution to #14 that complements this one

@mrjacobbloom
Copy link
Owner Author

mrjacobbloom commented Mar 4, 2020

What if simply getting global.Echo didn't trigger an autolog, but instead it waited until the first call/construct/get? Could just change the condition from maxTokensLength > 0 to 1.

Only makes sense if we've already figured out how to disable autocomplete

Breaks most trivial usage of Echo, which could lead to confusion

@mrjacobbloom
Copy link
Owner Author

mrjacobbloom commented Mar 6, 2020

There's an ownKeys handler

DevTools doesn't use the ownKeys handler, it hooks into v8 to inspect the object directly :/

@mrjacobbloom mrjacobbloom changed the title Keep exploring ways to disable log on autocomplete/eager-eval Disable log on autocomplete/eager-eval Mar 6, 2020
@mrjacobbloom
Copy link
Owner Author

Does Chrome even still eager-eval Echo?

It does not, and afaict adding side-effects to the internal Echo function causes no change in functionality

@mrjacobbloom
Copy link
Owner Author

Autocomplete seems to stop after a construct (potentially also a call) -- or does it? Maybe there's a way to take advantage of that?

It looks like autocomplete decides whether something has side effects based solely on the token types: https://github.com/ChromeDevTools/devtools-frontend/blob/e43879a5a25ec7bfaaedeb1e4d860181db696d09/front_end/formatter_worker/FormatterWorker.js#L463 Autocomplete is aborted if the expression contains anything that is not one of the "safe" types 'MemberExpression', 'Identifier', 'BinaryExpression', 'Literal', 'TemplateLiteral', 'TemplateElement', 'ObjectExpression', 'ArrayExpression', 'Property', 'ThisExpression'

@mrjacobbloom
Copy link
Owner Author

It looks like throwing an error could abort autocomplete -- is there a way to throw an error during the get handler without disrupting functionality?

@mrjacobbloom
Copy link
Owner Author

Oh god now new versions of Node (I'm playing with 14.15) do autocomplete too and it's so much worse in a CLI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work in progress A half-baked solution is probably already checked in
Projects
None yet
Development

No branches or pull requests

1 participant