repl icon indicating copy to clipboard operation
repl copied to clipboard

Large objects deadlock autocompletion

Open TimothyGu opened this issue 6 years ago • 3 comments

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)

TimothyGu avatar Jun 23 '18 04:06 TimothyGu

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?

antsmartian avatar Jul 18 '18 14:07 antsmartian

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

devsnek avatar Aug 21 '18 15:08 devsnek

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

cactysman avatar Aug 16 '19 12:08 cactysman