Skip to content

Chatterbox registers two accounts when first opened, then crashes #105

@Rhys-T

Description

@Rhys-T

Describe the bug
I'm trying to set up a self-hosted instance of Chatterbox in invite_user mode. When I first click on the Chatterbox button, it starts to open, creates the room, and sends the invitation, but then gets an error saying that room is undefined (t is undefined in the built version) and removes itself from the page. If I then reload the page and open Chatterbox again, it creates a second room, sends an invitation to that room, and works correctly from that point on. If I simulate being a new user (by clearing site data, opening a private window, or using a different browser), it fails again, then starts working again after a reload.

The error seems to be happening in Hydrogen's RoomViewModel class here, but that seems to be a result of Chatterbox passing in undefined as the room. I've managed to trace the problem to this part of createRoomWithUserSpecifiedInConfig:

const roomBeingCreated = this._session.createRoom({
type: 1, //todo: use enum from hydrogen-sdk here
name: undefined,
topic: undefined,
isEncrypted: this._options.config["encrypt_room"] ?? false,
isFederationDisabled: false,
alias: undefined,
avatar: undefined,
invites: [userId],
powerLevelContentOverride: powerLevelContent,
});
const roomStatusObservable = await this._session.observeRoomStatus(roomBeingCreated.id);
await roomStatusObservable.waitFor(status => status === (RoomStatus.BeingCreated | RoomStatus.Replaced)).promise;
const roomId = roomBeingCreated.roomId;
await this.platform.settingsStorage.setString("created-room-id", roomId);
await this.platform.settingsStorage.setString("invite-user", userId);
room = this._session.rooms.get(roomId);
return room;
It starts creating the room/invite, and waits for it to finish, but when it does, somehow the this._sessions.rooms map is completely empty.

To Reproduce
Steps to reproduce the behavior:

  1. Download and extract chatterbox-v0.5.2.tar.gz.
  2. Edit config.json. Fill out the homeserver and token settings. Replace the auto_join_room setting with invite_user, and set it to a Matrix user ID that you control.
  3. Create a basic index.html file, and add the embed code to it.
    1. Optional: The browser's devtools get confused when Chatterbox removes its iframe, and won't let you look at the code that's failing anymore. To prevent this, add HTMLIFrameElement.prototype.remove = function() { console.log('refusing to remove iframe', this); }; after the CHATTERBOX_CONFIG_LOCATION line.
  4. Upload the contents of the chatterbox-v0.5.2 folder to a web server, or serve it on localhost using something like httplz.
  5. Visit the server.
  6. Click on the Chatterbox button. It will open briefly and send the invite, then self-destruct.

OR

  1. git clone https://github.com/element-hq/chatterbox; cd chatterbox
  2. Edit public/config.json. Fill out the homeserver and token settings. Replace the auto_join_room setting with invite_user, and set it to a Matrix user ID that you control.
  3. yarn install
  4. yarn start
  5. Visit http://localhost:5400/
  6. Click on the Chatterbox button. It will open briefly and send the invite, then self-destruct.

Expected behavior
Chatterbox should remain open after creating the room even if the user is opening it for the first time.

Screenshots
N/A. There's not really anything to take a screenshot of once Chatterbox removes itself.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Firefox, Chrome
  • Version: Firefox 121.0.1, Chrome 120.0.6099.234

Smartphone (please complete the following information):
Not tested yet.

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
I was originally testing with Chatterbox running on http://localhost:8000, but I've also tried running it from a real https:// site, and am getting the same results there. I'm running Chatterbox v0.5.2 (or 86bc290 when trying the dev build, but the only changes since v0.5.2 seem to be in the readme).

I have it set to use a self-hosted Synapse homeserver. When I first noticed the issue, invite_user was set to a user on a different self-hosted Synapse, but it seems to happen even if the invite_user is on the same server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions