"Fatal undefined"
I'm trying to make a simple bot that responds to new members. I'm getting "Fatal undefined" which isn't helpful at solving the problem. Is there a way to better debug?
Thank you!
I'm having the same issue and no response on this thread makes me worried :crying_cat_face:
Can you describe how you are using the SDK? I agree it sounds like an unhelpful error. Hopefully we can figure it out!
(sry for reposting)
For me it's pretty basic stuff:
const sdk = require('matrix-js-sdk');
const myUserId = 'x';
const myAccessToken = 'xxx';
const matrixClient = sdk.createClient({
baseUrl: 'xxx',
accessToken: myAccessToken,
userId: myUserId
});
matrixClient.on('sync', (syncState, a, event) => {
console.log('syncState', syncState);
console.log('event', event);
console.log('a', a);
if (syncState === 'PREPARED') {
matrixClient.on("Room.timeline", function(event, room) {
('do stuff')
});
}
})
matrixClient.startClient();
node is outputting:
Got push rules
Sending first sync request...
syncState PREPARED
event { oldSyncToken: null,
nextSyncToken: 'xxx',
catchingUp: false }
a null
syncState SYNCING
event { oldSyncToken: null,
nextSyncToken: 'xxx',
catchingUp: false }
a PREPARED
Fatal undefined
('do stuff')
looks very invalid
What do you actually have here?
('do stuff')
It's valid JS (I just cut out the irrelevant part...), but it doesn't matter, because nothing inside matrixClient.on('sync', () => {}) is being executed. Let's change this to:
if (syncState === 'PREPARED') {
matrixClient.on("Room.timeline", function(event, room) {
console.log(event, room)
});
}
It just goes PREPARED => SYNCING and then Fatal undefined.
After a little digging i've found out that the piece of code from the docs is causing the trouble:
matrixClient.on("RoomMember.membership", function(event, member) {
if (member.membership === "invite" && member.userId === myUserId) {
matrixClient.joinRoom(member.roomId).done(function() {
console.log("Auto-joined %s", member.roomId);
});
}
});
But I'm not able to resolve this issue, so for the time being I will just comment this out.
--- EDIT
I've managed to gain more information - I've logged into riot web using the bot account and left the channel which was causing trouble. The bot was invited and then kicked from it.
I was also getting this error using a bot with only the auto-invite script just (like the comment above). Aside from matrixClient.start() or whatever, that was the only code.
It would crash right after starting, with the cryptic "Fatal undefined." Interesting that a room state could cause this.
EDIT: I had also kicked the bot from the room then re-invited it.