notwaldorf / tiny-care-terminal

💖💻 A little dashboard that tries to take care of you when you're using your terminal.
MIT License
5.96k stars 243 forks source link

Crash when counting commits in multiple repos #47

Open AndiDog opened 7 years ago

AndiDog commented 7 years ago

Node Version: v7.2.1 tiny-core-terminal version: 1.0.8 Shell: bash Terminal Program: iTerm2 Operating System: macOS

I have quite a few repos in ~/dev. The dashboard starts up, starts counting commits for a second and then crashes. Using TTC_REPOS=/single/repo works fine for the ones I tried. Didn't try very hard to debug into the blessed library since I don't know what the code is doing. What I can tell you that at that given code location in blessed (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/program.js:2543), we have part == "cpp" and val == "cpp".

Unsetting env vars other than TTC_REPOS doesn't make a difference.

$ set | grep TTC
TTC_APIKEYS=false
TTC_BOTS=tinycarebot,selfcare_bot
TTC_REPOS='~/dev'
TTC_WEATHER=Munich
$ tiny-care-terminal
TypeError: Cannot read property 'slice' of null
    at /usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/program.js:2543:35
    at Array.forEach (native)
    at Program._attr (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/program.js:2542:11)
    at Box.Element._parseTags (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/element.js:498:26)
    at Box.Element.parseContent (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/element.js:393:22)
    at Box.Element.render (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/element.js:1839:8)
    at /usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/screen.js:738:8
    at Array.forEach (native)
    at Screen.render (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/screen.js:735:17)
    at Socket.week.stdout.on.data (/usr/local/lib/node_modules/tiny-care-terminal/care.js:120:12)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at Pipe.onread (net.js:551:20)
notwaldorf commented 7 years ago

It looks like you only have 2 bots in TTC_BOTS -- i think that's where the slice is failing, maybe. Might adding a third?

AndiDog commented 7 years ago

I also tried with the default TTC_BOTS and an empty value. As mentioned, only the TTC_REPOS variable affects this issue.

notwaldorf commented 7 years ago

I really can't repro this, nor have heard of anyone else having problems in this way :(

AndiDog commented 7 years ago

Then I'm happy for everyone else 👍 I'll leave this open and try to debug myself.

notwaldorf commented 7 years ago

As of version 1.2.0 there's a new way to use the terminal that doesn't involve the bash script/ Would you mind updating to that and setting the TTC_GITBOT environment variable to gitlog, to see if that fixes your problems?

AndiDog commented 7 years ago

The problem resolved on its own recently. Hard to find out afterwards what the real reason was (such as the state of my 200+ Git repos)... 1.2.0 is also working fine for me. We can close this and hope it doesn't happen anymore ;) Thanks!

jarednorman commented 7 years ago

I'm also getting this error, and it's caused by a specific one of my git repos, it seems. :cry:

notwaldorf commented 7 years ago

@jarednorman I've noticed I couldn't use a git repo with a dot in the name. Maybe it's that? :(

jarednorman commented 7 years ago

No dot or any other weird characters. It's just of the format "fooBar".

mojoaxel commented 7 years ago

I've noticed I couldn't use a git repo with a dot in the name. Maybe it's that? :(

@notwaldorf Is this a git-log or an git-standup issue? I think this should be fixed!

jarednorman commented 7 years ago

Changing between git-log/git-standup has no effect on the error for me. The only thing that changes whether I get this error is whether I include this one repo I have in TTC_REPOS.

jarednorman commented 7 years ago

Mysteriously just started working today. :confounded:

cfinucane commented 7 years ago

I had the same problem, and traced it to curly braces in the commit messages wreaking havoc with the "tag parser" implemented in the blessed library. The simplest fix is to set tags: false in makeBox(), but I'm not sure if there is an unrelated reason it needs to be set to true. The alternative is to do something like content = content.replace(/[{}]/g, m => m === '{' ? '{open}' : '{close}'); inside getCommits(). Happy to submit a tiny-PR if you let me know which solution you think would be more appropriate :)

timbeadle commented 6 years ago

I also had this problem with just one repo, which had curly braces in commit messages. I applied @cfinucane's patch and it works. 😀

LeoniePhiline commented 6 years ago

Having the same issue:

TypeError: Cannot read property 'slice' of null
    at /usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/program.js:2543:35
    at Array.forEach (<anonymous>)
    at Program._attr (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/program.js:2542:11)
    at Box.Element._parseTags (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/element.js:498:26)
    at Box.Element.parseContent (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/element.js:393:22)
    at Box.Element.render (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/element.js:1839:8)
    at /usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/screen.js:738:8
    at Array.forEach (<anonymous>)
    at Screen.render (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/blessed/lib/widgets/screen.js:735:17)
    at gitbot.getCommitsFromRepos (/usr/local/lib/node_modules/tiny-care-terminal/care.js:207:16)
    at async.each.err (/usr/local/lib/node_modules/tiny-care-terminal/gitbot.js:88:5)
    at /usr/local/lib/node_modules/tiny-care-terminal/node_modules/async/lib/async.js:52:16
    at done (/usr/local/lib/node_modules/tiny-care-terminal/node_modules/async/lib/async.js:246:17)
    at /usr/local/lib/node_modules/tiny-care-terminal/node_modules/async/lib/async.js:44:16
    at gitlog (/usr/local/lib/node_modules/tiny-care-terminal/gitbot.js:82:9)
    at /usr/local/lib/node_modules/tiny-care-terminal/node_modules/gitlog/index.js:132:5
> node -v
v8.11.2
> npm -v
5.6.0

Probably also due to commits titled like

Rename ./build{,-dev}.sh to ./webpack-build{,-dev}.sh

For me it was also "fixed" by changing the tags: option in function makeBox(label) to false. (In /usr/local/bin/tiny-care-terminal)

@AndiDog Would you reopen and apply @cfinucane 's patch? :)

mojoaxel commented 6 years ago

I won't find the time in the near future to work on this issue. Maybe somebody can create a pull-request? It shouldn't be that hard. :crossed_fingers: