Uh oh!
There was an error while loading. Please reload this page.
repl: exports Recoverable - #3488
Conversation
jasnell
commented
Oct 22, 2015
No opinion yet on the actual change, but a test case and doc+example would be helpful on this kind of change |
bnoordhuis
commented
Oct 22, 2015
#2939 says it's so |
blakeembrey
commented
Oct 22, 2015
@bnoordhuis Do you have any other thoughts on it? I thought it was actually a pretty clean solution to give control to the consumer. The alternative of using a function option to check [the eval error] wouldn't be ideal for places where the code is being statically analyzed, like TypeScript. @jasnell Sure, I can add some docs/example - do you have an existing or similar test I can use for reference here? I didn't see an existing multi-line test (I'm sure I probably missed it this morning). |
Trott
commented
Oct 23, 2015
If I'm understanding "multi-line test" correctly (a test for the REPL that involves sending some stuff and then a new line with some more stuff), there are indeed ones you can use as models. One is in (Node 4.2.1 blows up at the It in turn was modeled on the more general (And if I'm misunderstanding your question, sorry for the noise.) |
ac60691 to
57b3299Compareblakeembrey
commented
Oct 23, 2015
@Trott Thanks for the link, just wrote a similar test 😄 |
57b3299 to
fba0d43Compareblakeembrey
commented
Oct 23, 2015
@jasnell Updated the |
Fishrock123
commented
Oct 26, 2015
The example makes sense, but I wonder if it isn't relying in implementation details too much? @blakeembrey if you were to suggest an ideal API for this, what would it look like? Would it look any different? |
blakeembrey
commented
Oct 28, 2015
@Fishrock123 I was thinking about it, and this is pretty ideal already. In fact, it's how I'd want to consume it - I'd filter recoverable errors from TypeScript diagnostics and then hand the execution back to |
ggentzke
commented
Nov 12, 2015
Commenting for attention as I've been encountering this issue recently and found my way here through nodejs/node-v0.x-archive#8640. |
Trott
commented
Nov 12, 2015
There was a problem hiding this comment.
Have we defined this anywhere in the docs?
There was a problem hiding this comment.
No, I can add it - it was only an example, but the actual implementation of isRecoverableError could be much complicated. Is there a psuedo-function I should show here?
There was a problem hiding this comment.
@blakeembrey Can we use the simplified form of the one actually used by REPL. May be something like
functionisRecoverableError(e){if(e&&e.name==='SyntaxError'){if(e.message==='Missing } in template expression'){returntrue;}return/^(Unexpectedendofinput|Unexpectedtoken)/.test(e.message);}returnfalse;}There was a problem hiding this comment.
Added your snippet to the PR.
There was a problem hiding this comment.
@blakeembrey To think of it, this part
if(e.message==='Missing } in template expression'){returntrue;}may not be readily understandable for the users. So, lets remove that part alone.
There was a problem hiding this comment.
So, lets remove that part alone.
What do you mean by this? Shouldn't this be removed all together, the following regexp test is pretty clear.
There was a problem hiding this comment.
Only the if condition I mentioned above can be removed., So it will look like this
functionisRecoverableError(e){if(e&&e.name==='SyntaxError'){return/^(Unexpectedendofinput|Unexpectedtoken)/.test(e.message);}returnfalse;}There was a problem hiding this comment.
Already updated below. I'm only using error.name because it's assumed the try..catch would have an error object already to check.
e59ab0e to
159e3afComparethefourtheye
commented
Nov 13, 2015
Change LGTM. If there is no other better option, then we can go ahead with this. @bnoordhuis thoughts? |
159e3af to
416769aComparebnoordhuis
commented
Nov 13, 2015
I still appreciate the spirit if not the actual implementation of this PR. :-) I'm also not sure if it's correct in all cases. The actual check in if(einstanceofRecoverable&&!self.lineParser.shouldFail){If |
thefourtheye
commented
Nov 13, 2015
Oh yeah. You are correct. Users cannot override comments check and string literal checks. |
anshumanf
commented
Nov 13, 2015
This would likely fix babel/babel#1741 |
blakeembrey
commented
Nov 13, 2015
@bnoordhuis You're right, I can move the line parser into the JavaScript eval implementation. |
ghost
commented
Nov 13, 2015
Closely following this. If fixed this would help improve my workflow in babel. Thanks for the effort. |
blakeembrey
commented
Nov 13, 2015
@bnoordhuis Now I see now why I missed it. It was added after I opened this PR. I'm going to refactor it into the eval implementation (edit: today or tomorrow). Edit: 6cf1910 |
blakeembrey
commented
Nov 13, 2015
@bnoordhuis@thefourtheye Ok, it's a bit more complicated now since a bit of it is tightly coupled and other parts I'm not sure actually work as expected. I can still update this with the same changes, but things like the "saved RegExp population" - wouldn't that currently be failing when run in the non-global context? Edit: Another bug. The "line parser" is trimming whitespace and not handling template strings, so any trailing whitespace is lost. Edit 2: Another issue. Chaining in the CLI? Any lines that start with |
416769a to
283323fCompareblakeembrey
commented
Nov 14, 2015
@bnoordhuis@thefourtheye I made some refactors and improvements to the line parser code. It only runs on a syntax error now, but it's running within the context of Edit: If it makes sense now too, I'm open to making a new PR for this outside of this one and rebasing it back when it's merged. |
bnoordhuis
commented
Nov 18, 2015
I'm going to decline reviewing this but e.g. @thefourtheye is welcome to pick it up. |
blakeembrey
commented
May 7, 2016
@mscdex Thanks, fixed that. I didn't recall an option just to run linting. |
mscdex
commented
May 7, 2016
@blakeembrey Ah yeah, |
blakeembrey
commented
May 7, 2016
Cool, thanks. Should have seen it 😄 Anyway, passed locally - did a full test. |
Allow REPL consumers to callback with a `Recoverable` error instance and trigger multi-line REPL prompts. Fixes: nodejs#2939 PR-URL: nodejs#3488 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Fishrock123
commented
May 12, 2016
Thanks! Landed in 9552e3b @blakeembrey sorry for the extremely long delay on this.. 😓 |
blakeembrey
commented
May 12, 2016
Awesome! Thank you 😄 Next is #6171. |
- **buffer**: fix lastIndexOf and indexOf in various edge cases (Anna Henningsen) [#6511](#6511) - **child_process**: use /system/bin/sh on android (Ben Noordhuis) [#6745](#6745) - **deps**: - upgrade npm to 3.8.9 (Rebecca Turner) [#6664](#6664) - upgrade to V8 5.0.71.47 (Ali Ijaz Sheikh) [#6572](#6572) - upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) [#6796](#6796) - Intl: ICU 57 bump (Steven R. Loomis) [#6088](#6088) - **repl**: - copying tabs shouldn't trigger completion (Eugene Obrezkov) [#5958](#5958) - exports `Recoverable` (Blake Embrey) [#3488](#3488) - **src**: add O_NOATIME constant (Rich Trott) [#6492](#6492) - **src,module**: add --preserve-symlinks command line flag (James M Snell) [#6537](#6537) - **util**: adhere to `noDeprecation` set at runtime (Anna Henningsen) [#6683](#6683) As of this release the 6.X line now includes 64-bit binaries for Linux on Power Systems running in big endian mode in addition to the existing 64-bit binaries for running in little endian mode. PR-URL: #6810
- **buffer**: fix lastIndexOf and indexOf in various edge cases (Anna Henningsen) [#6511](#6511) - **child_process**: use /system/bin/sh on android (Ben Noordhuis) [#6745](#6745) - **deps**: - upgrade npm to 3.8.9 (Rebecca Turner) [#6664](#6664) - upgrade to V8 5.0.71.47 (Ali Ijaz Sheikh) [#6572](#6572) - upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) [#6796](#6796) - Intl: ICU 57 bump (Steven R. Loomis) [#6088](#6088) - **repl**: - copying tabs shouldn't trigger completion (Eugene Obrezkov) [#5958](#5958) - exports `Recoverable` (Blake Embrey) [#3488](#3488) - **src**: add O_NOATIME constant (Rich Trott) [#6492](#6492) - **src,module**: add --preserve-symlinks command line flag (James M Snell) [#6537](#6537) - **util**: adhere to `noDeprecation` set at runtime (Anna Henningsen) [#6683](#6683) As of this release the 6.X line now includes 64-bit binaries for Linux on Power Systems running in big endian mode in addition to the existing 64-bit binaries for running in little endian mode. PR-URL: #6810
Allow REPL consumers to callback with a
Recoverableerror instance and trigger multi-line REPL prompts.Closes#2939