superscriptjs / superscript

A dialogue engine for creating chat bots
http://superscriptjs.com
MIT License
1.65k stars 209 forks source link

I easily crash the telnet server without a good warning #368

Closed jloveric closed 7 years ago

jloveric commented 7 years ago

I should be able to type any question without crashing the server, or at least get a good explanation for why.

Trying ::1...
Connected to localhost.
Escape character is '^]'.
Welcome to the Telnet server!
Hello ::1:61222! Type /quit to disconnect.

You> hello

Bot> Ola
You> hello

Bot> How are you?
You> good

after typing "good", telnet crashes. Not sure what the issue is, could be mongo or anything else, but appears to be in wordnet if result.pos is undefined.

node_modules/node-wordnet/lib/wordnet.js:431
        exceptions[result.pos] = result.data;

TypeError: Cannot read property 'pos' of undefined
    at /node_modules/node-wordnet/lib/wordnet.js:431:26
    at /node_modules/node-wordnet/node_modules/async/lib/async.js:251:17
    at done (/node_modules/node-wordnet/node_modules/async/lib/async.js:126:15)
    at /node_modules/node-wordnet/node_modules/async/lib/async.js:32:16
    at /node_modules/node-wordnet/node_modules/async/lib/async.js:248:21
    at ReadFileContext.callback (/node_modules/node-wordnet/lib/wordnet.js:406:18)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:359:13)

This is on macosx

rensdewolf commented 7 years ago

I experienced the same issue some time ago. The problem seems to be a path mismatch for the wndb-with-exceptions node module. In my case it expected the exception files (adj, adv, noun and verb) in the dict subfolder but they were located in the data subfolder. My quick workaround was to simply to copy these exception files to the data subfolder. Not sure where this should/could be fixed though.

bensalilijames commented 7 years ago

I can't reproduce this issue, and nothing has changed in the node-wordnet or wndb-with-exceptions module since an unrelated tar issue, so I'm not sure what's going on here!

Steps I took:

yarn global add superscript
bot-init testbot
cd testbot
yarn
parse
yarn run start-telnet
telnet localhost 2000

And then I said a few things including 'hi' and 'good', both work fine.

Are there steps I'm missing here? BTW I did also try with npm just in case postinstall was behaving differently, but in this case it made no difference.

antonispoulakis commented 7 years ago

Perhaps the node/npm version plays a part?

I have run it in node versions 6.11.0 and 8.1.4 and it throws the same error.

The wndb-with-exceptions module has the files in the correct folder for me.

bensalilijames commented 7 years ago

I ran it in node 8.1.4, with both npm@5 and yarn@0.27, without error.

antonispoulakis commented 7 years ago

Hm, I just run it in 6.11.0 and it didn't throw the error. I tested both a new project and the one I am working on, and it didn't crash.

bensalilijames commented 7 years ago

Spooky! I'll close this issue for now until there's a good repro, feel free to re-open anytime. :+1:

Lewwwk commented 7 years ago

Just logging an instance of this.

Just did a reinstall, ran parse.js, then ran cleanup.js, and in my first telnet message to the bot it crashed.

.../node_modules/node-wordnet/lib/wordnet.js:431
        exceptions[result.pos] = result.data;
                         ^

TypeError: Cannot read property 'pos' of undefined

Ran cleanup.js again, and can no longer produce. Strange indeed.

CORRECTION: It is still happening. Continuing to investigate.

Lewwwk commented 7 years ago

Confirming the temporary fix suggested by @rensdewolf.

Lewwwk commented 7 years ago

@benhjames I wouldn't be surprised if the issue is with the tar issue - as what is happening is that the files aren't being copied from /data to /dict. Haven't yet solved - or figured out why this is just happening now for me after this reinstall. It is consistent and repeatable though.