Spectrum: Threads crashing spectrum

Created on 21 May 2018  路  13Comments  路  Source: withspectrum/spectrum

All 13 comments

FWIW, for https://spectrum.chat/thread/f58380fe-be5d-4b87-91ee-e2f2423014d4 the empty body seems to be the root cause.

screen shot 2018-05-21 at 11 06 02 am

I know the cause of the first one:

If a user composes a thread on Android, the thread type is set to TEXT. In the mutation, we check for these text types and convert them to draft state. However, the logic is this:

if (type === 'TEXT') {
    type = 'DRAFTJS';
    if (thread.content.body) {
      thread.content.body = JSON.stringify(
        markdownToDraft(thread.content.body)
      );
    }
  }

As you can see, a thread composed on android without a body will not have any draft state set as the content.body, which crashes everything on the frontend.

A thread without a body should be converted to draftjs state like so:

"content": {
  "body": "{"blocks":[{"key":"foo","text":"","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}}],"entityMap":{}}" ,
  "title":  "Test"
} ,

cc @mxstbr :)

Let's add a resolver for the body field that returns "{}" if the body in the db is "" and the type is draft, that should fix it immediately for everybody?

I will try

I will try locally now.

Kk #3128 fixes the first thread crash listed in this issue. The chat input crashing on the second thread is still a mystery

@brianlovin @mxstbr I managed to replicate the chat issue locally. Create a thread and only add a block of code in the body.

@alejandronanez hm I can't repro with that step - I'm still able to type in the chat input

Try this:

  1. Create the thread with only a block of code in it
  2. Refresh the page
  3. Click the chat input.

chat-input-error

:)

Ah, it needed a refresh. Good call - this is super weird cc @mxstbr

Here's the warning:
screenshot 2018-05-21 10 40 37

And deprecation link: https://www.chromestatus.com/features/6680566019653632

Digging in to see if other people are experiencing this....although it's bizarre that the thread content would impact the chat input in this way.

Another interesting side effect of this:

if you create a thread where the body is only a code block, then you go to edit the thread, it's not possible to escape the code block.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

atlx picture atlx  路  5Comments

mxstbr picture mxstbr  路  6Comments

zefexdeveloper picture zefexdeveloper  路  5Comments

mxstbr picture mxstbr  路  3Comments

mxstbr picture mxstbr  路  5Comments