Skip to content

Conversation

rlidwka
Copy link
Contributor

@rlidwka rlidwka commented Jul 5, 2015

The issue is described here: #1968

I consider keypress event in readline a public api, and if such a handler throws, readline should continue to work normally.

Basically, I see are two good ways to deal with it:

  1. restart the generator when it errors out
  2. throw an error in the next tick

Since everything in readline is synchronous now, adding nextTick would break things. So I went with option 1.

This PR fixes a particular bug. But avoiding throwing in repl might still be a good idea. So PR #1968 might still make sense, but as a refactor, not a bugfix (I'll let someone else to review it though).

// cc: @monsanto

`emitKeys` is a generator which emits `keypress` events in an infinite
loop. But if `keypress` event handler throws, the error stops the loop,
leaving generator in a broken state. So this patch restarts the generator
when an error occures.
@mscdex mscdex added the readline Issues and PRs related to the built-in readline module. label Jul 5, 2015
@monsanto
Copy link
Contributor

monsanto commented Jul 6, 2015

I agree that if keypress is a public API it should not error out. It should be documented though.

LGTM

@Fishrock123
Copy link
Contributor

LGTM.

rlidwka added a commit that referenced this pull request Jul 11, 2015
`emitKeys` is a generator which emits `keypress` events in an infinite
loop. But if `keypress` event handler throws, the error stops the loop,
leaving generator in a broken state. So this patch restarts the generator
when an error occures.

PR-URL: #2107
Reviewed-By: Christopher Monsanto <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
@rlidwka
Copy link
Contributor Author

rlidwka commented Jul 11, 2015

landed in bd01603

@rlidwka rlidwka closed this Jul 11, 2015
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Jul 17, 2015
Notable changes

* src: Added a new `--track-heap-objects` flag to track heap object
allocations for heap snapshots (Bradley Meck)
nodejs#2135.
* readline: Fixed a freeze that affected the repl if the keypress event
handler threw (Alex Kocharin) nodejs#2107.
* npm: Upgraded to v2.13.0, release notes can be found in
https://github.com/npm/npm/releases/tag/v2.13.0 (Forrest L Norvell)
nodejs#2152.

PR-URL: nodejs#2189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readline Issues and PRs related to the built-in readline module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants