Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'content' of null causes timestamp on post to duplicate for a few seconds #1087

Closed
dsevillamartin opened this issue Dec 14, 2016 · 17 comments

Comments

@dsevillamartin
Copy link
Member

dsevillamartin commented Dec 14, 2016

Bug report

  • Version of Flarum: v0.1.0-beta.6 or maybe dev-master (it's Flarum Discuss)
  • Website URL where the bug is visible: Happens randomly and then restores itself.

Error

Uncaught TypeError: Cannot read property 'content' of null
    at forum-70f79e94.js:652

Additional comments

I sent many posts to https://discuss.flarum.org/d/4458, and from time to time the timestamps on a few posts got duplicated, and then went back to their normal state. It happened three times, and when I checked the console, there were three errors there that were the same. The error itself can be found above.

It seems to be a bug with the composer itself... That position currently has app.composer.component.content(), which I'm guessing that's a Mithril prop and it's clearing the composer's text content.

img
img2

@dav-is
Copy link

dav-is commented Dec 15, 2016

That position currently has app.composer.component.content(), which I'm guessing that's a Mithril prop and it's clearing the composer's text content.

This code wouldn't erase the content but get it. For instance,
this.props.foo('bar'); sets foo as bar, while this.props.foo(); returns bar.

@dsevillamartin
Copy link
Member Author

@dav-is Oh, true, I forgot how Mithril props work. But still, this means that the JS is trying to get the composer's text after submitting the new post... with what purpose?

@dav-is
Copy link

dav-is commented Dec 15, 2016

The error indicates app.composer.component is null, not the content. Probably should just use app.composer.content() instead.

@dsevillamartin
Copy link
Member Author

app.composer.component only exists when the composer is in the DOM, and app.composer.content is undefined. It could probably just do app.composer.component && app.composer.component.content(), to be honest.

@tobyzerner
Copy link
Contributor

tobyzerner commented Dec 17, 2016

I believe duplicate timestamps is a complex Mithril diff algorithm bug (unrelated to the composer) and will hopefully be fixed with Mithril 1.0.

@datitisev which line of code is that exactly?

@dsevillamartin
Copy link
Member Author

I managed to get the error again, although it is slightly different.

forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)
    (anonymous function) @ forum-70f79e94.js:652

And that line is actually the onunload method in DiscussionPage, when it tries to hide/close the composer if there is content or no content respectively.

My console is getting spammed, I have 600+ errors from this.

forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)(anonymous function) @ forum-70f79e94.js:652
forum-70f79e94.js:652 Uncaught TypeError: Cannot read property 'content' of null(…)

Let me try again to see what steps I took to break it.

@dsevillamartin
Copy link
Member Author

Ok. Steps to reproduce:

  1. Go to a discussion
  2. Refresh
  3. Click "Write a reply" at the bottom
  4. Don't type anything
  5. Click the back button at the top (the < = menu thingy)
  6. Check console

It doesn't seem to bug out anything anymore, but it does spam the console pretty quickly

screen shot 2016-12-17 at 10 19 43 am

@kajack
Copy link

kajack commented Dec 21, 2019

Is this solved? Because I'm facing this issue.

@dsevillamartin
Copy link
Member Author

@kajack Has it just occurred once or can you reproduce the error consistently?

@kajack
Copy link

kajack commented Dec 22, 2019

@datitisev Everytime I reply a post, it appears. I don't remember but somewhere ended in an endless loop creating over 1k errors of those.

Any way to fix it or debug it?

@luceos
Copy link
Member

luceos commented Dec 22, 2019

@kajack please post the output of php flarum info and confirm whether the steps to reproduce match with yours or there are differences.

@kajack
Copy link

kajack commented Dec 22, 2019

Okay, so basically.

  1. Log in the forum.
  2. Enter any post.
  3. Reply with something.
  4. The error appears there in the console.
Flarum core 0.1.0-beta.11.1
PHP version: 7.3.11
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, pcntl, readline, Reflection, SPL, session, standard, bcmath, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, intl, json, exif, mysqlnd, odbc, PDO, pgsql, Phar, posix, shmop, SimpleXML, soap, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlwriter, xsl, zip, mysqli, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, wddx, xmlreader, xmlrpc, Zend OPcache
+-------------------------------+----------------+--------+
| Flarum Extensions             |                |        |
+-------------------------------+----------------+--------+
| ID                            | Version        | Commit |
+-------------------------------+----------------+--------+
| flarum-approval               | v0.1.0-beta.8  |        |
| flarum-bbcode                 | v0.1.0-beta.8  |        |
| flarum-emoji                  | v0.1.0-beta.10 |        |
| flarum-lang-english           | v0.1.0-beta.11 |        |
| flarum-flags                  | v0.1.0-beta.10 |        |
| flarum-lock                   | v0.1.0-beta.9  |        |
| flarum-markdown               | v0.1.0-beta.10 |        |
| flarum-mentions               | v0.1.0-beta.10 |        |
| flarum-statistics             | v0.1.0-beta.9  |        |
| flarum-sticky                 | v0.1.0-beta.9  |        |
| flarum-subscriptions          | v0.1.0-beta.9  |        |
| flarum-suspend                | v0.1.0-beta.10 |        |
| flarum-tags                   | v0.1.0-beta.11 |        |
| clarkwinkelmann-circle-groups | 0.2.1          |        |
| v17development-seo            | 1.0.2          |        |
| fof-nightmode                 | 0.3.0          |        |
| fof-spamblock                 | 0.2.1          |        |
| fof-gamification              | 0.1.6          |        |
| flagrow-analytics             | 0.8.0          |        |
| flagrow-sitemap               | 0.2.0          |        |
| fof-follow-tags               | 0.3.4          |        |
| flagrow-ads                   | 0.2.4          |        |
| fof-default-group             | 0.1.0          |        |
| fof-links                     | 0.2.1          |        |
| fof-pages                     | 0.2.7          |        |
| maicol07-sso                  | 1.3.2          |        |
| flagrow-upload                | 0.7.1          |        |
| fof-socialprofile             | 0.1.1          |        |
+-------------------------------+----------------+--------+
Base URL: https://forum.moonquill.com
Installation path: /var/app/current
Debug mode: off

@franzliedke
Copy link
Contributor

@kajack Thanks for the reproduction info!

@datitisev Strange... how can the component be null in that line when, right before that, we call composingReplyTo which checks that the component is of type ReplyComposer? 🤔

https://github.com/flarum/core/blob/104d3982fe76f7481bbb957b064e0315314ba118/js/src/forum/ForumApplication.js#L126

@dsevillamartin
Copy link
Member Author

dsevillamartin commented Jan 3, 2020

@franzliedke Uh.... I haven't got the foggiest idea. And this might not be a bug anymore, I'm unable to reproduce with the steps I laid out.

I'll try it with an older beta and the extensions provided in the PHP info above to see if I can reproduce it. It could've always been fixed but an extension may be now causing it with a slightly different stack trace.

@franzliedke
Copy link
Contributor

I couldn't find a recent occurrence in our Sentry logs, but that doesn't mean it doesn't happen. 😉

@kajack If it's not too much work, could you try to reproduce it on a) your forum, with all extensions disabled and b) on https://nightly.flarum.site/? That would help a lot!

@askvortsov1
Copy link
Member

I can no longer reproduce this, I believe it was solved either in #2161 or in #2255. Feel free to reopen if anyone finds this again

@matteocontrini
Copy link
Contributor

@askvortsov1 shouldn't this be added to the beta14 milestone, perhaps? Together with other recently closed issues, actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants