dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

TypeError: Cannot read property 'substring' of undefined #163

Open sheerun opened 8 years ago

sheerun commented 8 years ago

I get following error when running node app using vorpal with docker-compose.

I use following docker-compose.yml:

version: '2'
services:
  web:
    image: node:4-slim
    volumes:
      - .:/app
    command: node /app/dist/index.js
    links:
      - db

dist/index.js is just a simple script express server with vorpal attached. It works outside of docker.

dthree commented 8 years ago

Can you print the whole stack and any additional related code?

sheerun commented 8 years ago

I was unable to retrieve the stacktrace, but here's gist to reproduce the error:

https://gist.github.com/sheerun/474c852350c217fbdf0c9bd954ec7c3f

The command to run is npm install && docker-compose up

sheerun commented 8 years ago

This only happens when enabling cli terminal with show() command.

sheerun commented 8 years ago

I needed to edit vorpal to catch the error. It's too bad you don't re-throw exceptions, but swallow them :(

web_1  | Vorpal Prompt error: TypeError: Cannot read property 'substring' of undefined
web_1  |     at Interface.rl._getCursorPos (/app/node_modules/readline2/index.js:55:51)
web_1  |     at ScreenManager.render (/app/node_modules/inquirer/lib/utils/screen-manager.js:19:27)
web_1  |     at Prompt.render (/app/node_modules/inquirer/lib/prompts/input.js:75:15)
web_1  |     at Prompt.inquirer.prompt.prompts.input.render (/app/node_modules/vorpal/lib/ui.js:78:23)
web_1  |     at Prompt._run (/app/node_modules/inquirer/lib/prompts/input.js:49:8)
web_1  |     at Prompt.run (/app/node_modules/inquirer/lib/prompts/base.js:57:8)
web_1  |     at Object.<anonymous> (/app/node_modules/inquirer/lib/ui/prompt.js:83:12)
web_1  |     at module.exports (/app/node_modules/run-async/index.js:15:21)
web_1  |     at /app/node_modules/inquirer/lib/utils/utils.js:16:7
web_1  |     at tryCatcher (/app/node_modules/rx-lite/rx.lite.js:537:29)
web_1  |
sheerun commented 8 years ago

To be honest, it's hard to enable cli in docker-compose, as it outputs logs and is not interactive, but I'd expect appropriate notification instead of such weird error.

dthree commented 8 years ago

Thanks. This is interesting - it's hitting some sort of conflict in Inqurier.js. Will check out further.

dthree commented 8 years ago

var strBeforeCursor = this._prompt + this.line.substring(0, this.cursor);

this.line is undefined in the readline2 module. Something like this usually happens when another module is already messing with readline, and it creates conflicts. I'm not very familiar with docker-compose, so I'll check out further.

Can you try to reproduce this with straight-up Vorpal and not Vantage? Wondering if its a version issue.

sheerun commented 8 years ago

It happens only with vantage

dthree commented 8 years ago

Hmmm. Okay got it.