nodejs / repl

REPL rewrite for Node.js ✨🐢🚀✨
MIT License
177 stars 25 forks source link

Large objects deadlock autocompletion #9

Open TimothyGu opened 6 years ago

TimothyGu commented 6 years ago

https://github.com/devsnek/node-repl-prototype/blob/5e72bed5a127c0b3e1c7289d75c3eb157db43522/src/repl.js#L146-L149

getProperties doesn't allow any sort of timeout, so it will take forever for an object like Array(1000000).fill(0)

antsmartian commented 6 years ago

Ok this is interesting. I'm not sure, why we do call onAutocomplete when user types in .? Also, the same code snippet works perfectly fine in normal repl along with proper tab completion. A quick question here can't we simply use Object.getOwnPropertyNames() to get the list of method names here rather than using Runtime.getProperties are there any advantages here?

devsnek commented 6 years ago

I'm going to try and add a timeout to Runtime.getProperties

cactysman commented 5 years ago

I'm not too experienced with child processes in NodeJS (child_process module), but would moving autocompletion / eager evaluation to a killable fork make sense? The result would then be shown asynchronously.

When the input is submitted or is changed to something syntactically different (if there's efficient ways to check this, something like removing a semicolon at the very end shouldn't re-trigger it), the fork could be killed off and the new thing would be evaluated.

Example from the Chrome devtools (although they don't kill it if it doesn't complete quickly enough but instead it clogs the main process): tWgD3PXeW5