pagermon: TypeError: Cannot read property '1' of null
Crashed today with this message. Running on Raspberry Pi.
readline.js:1032
throw err;
^
TypeError: Cannot read property '1' of null
at Interface.rl.on (/home/pi/pagermon/client/reader.js:104:48)
at Interface.emit (events.js:189:13)
at Interface._onLine (readline.js:290:10)
at Interface._line (readline.js:638:8)
at Interface._ttyWrite (readline.js:926:16)
at Socket.onkeypress (readline.js:168:10)
at Socket.emit (events.js:189:13)
at emitKeys (internal/readline.js:424:14)
at emitKeys.next (<anonymous>)
at Socket.onData (readline.js:1022:36)
Signal caught, exiting!
User cancel, exiting...
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (2 by maintainers)
replace line 121 of reader.js with the following
message = line.match(/FLEX[:|].*[|\[][0-9 ]*[|\]] ?...[ |]{0,1}(.*)/)[1].trim();I was only given one example of a message that causes this and slightly modified the regex so that [1] is always defined. I actually did that back in 2021 and with the single example provided, it fixed the issue.
You can see here with new regex, the line matches and group 1 is defined, but empty: https://regex101.com/r/S8HMZv/1 This is the old regex, where group 1 is undefined, because the regex doesn’t match at all: https://regex101.com/r/BdxbfY/1
There was a PR that involved wrapping statements in try/catch, but i dont think it was finished. Then reader.js was rewritten and I lost track of who was doing what. Anyway, that will solve it.
If you want to prevent reader.sh from stopping when it encounters an error, you can also do this (where … is your existing config, just add “do” to the start of that line):
that will restart the reader after a 10 second delay if something causes it to fail