GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — readline: fix freeze if `keypress` event throws by rlidwka · Pull Request #2107 · nodejs/node

Conversation

@rlidwka

@rlidwka rlidwka commented Jul 5, 2015

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rlidwka
readline: fix freeze if keypress event throws
2c84c94
`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

monsanto commented Jul 6, 2015

Copy link
Copy Markdown
Contributor

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

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jul 7, 2015

Copy link
Copy Markdown
Contributor

LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rlidwka added a commit that referenced this pull request Jul 11, 2015
@rlidwka
readline: fix freeze if keypress event throws
bd01603
`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

rlidwka commented Jul 11, 2015

Copy link
Copy Markdown
Contributor Author

landed in bd01603

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rlidwka rlidwka closed this Jul 11, 2015
@Fishrock123 Fishrock123 mentioned this pull request Jul 16, 2015
Release Proposal: v2.4.0 #2189
Merged
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Jul 17, 2015
@Fishrock123
2015-07-17 io.js v2.4.0 Release
a179bcb
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
@jasnell jasnell mentioned this pull request Nov 16, 2015
repl: fix freeze if util.inspect throws & clean up error handling a bit #1968
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@rlidwka @monsanto @Fishrock123 @mscdex
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.