nextcloud / notifications

🔔 Notifications app for Nextcloud
GNU Affero General Public License v3.0
116 stars 56 forks source link

Request for notifications-new.svg is made and immediately cancelled #945

Closed timreeves closed 3 years ago

timreeves commented 3 years ago

Steps to reproduce

  1. Log in and see your dashboard
  2. Check the network activity in the browser debugger - you'll see /apps/notifications/img/notifications-new.svg (canceled)
  3. Check the nginx webserver log, you'll see /apps/notifications/img/notifications-new.svg code 499 (client closed the connection)

Expected behaviour

Why on earth does the FE make a request and immediately cancel it? This causes a code 499 log entry in nginx. I'm unhappy about this as I want to monitor the logs with Fail2Ban as a security measure, and all "weird" messages are a headache, in fact all messages which are avoidable are unwanted, as when the logs get too long then race conditions happen bewteen the webserver writing logs and fail2ban monitoring them.

Actual behaviour

499, client cancels the request it just made

Server configuration

Operating system: Debian 9

Web server: Nginx

Database: MariaDB

PHP version: 7.3

Nextcloud version: Nextcloud 20.0.9

Where did you install Nextcloud from: Manually years ago, Updater since

Signing status: ?

No errors have been found.

List of activated apps:

Enabled:
  - accessibility: 1.6.0
  - activity: 2.13.4
  - bruteforcesettings: 2.1.0
  - calendar: 2.2.0
  - cloud_federation_api: 1.3.0
  - comments: 1.10.0
  - contacts: 3.5.1
  - contactsinteraction: 1.1.0
  - dashboard: 7.0.0
  - dav: 1.16.2
  - federatedfilesharing: 1.10.2
  - files: 1.15.0
  - files_external: 1.11.1
  - files_pdfviewer: 2.0.1
  - files_rightclick: 0.17.0
  - files_sharing: 1.12.2
  - files_trashbin: 1.10.1
  - files_versions: 1.13.0
  - files_videoplayer: 1.9.0
  - logreader: 2.5.0
  - lookup_server_connector: 1.8.0
  - mail: 1.9.5
  - nextcloud_announcements: 1.9.0
  - notifications: 2.8.0
  - oauth2: 1.8.0
  - password_policy: 1.10.1
  - photos: 1.2.3
  - privacy: 1.4.0
  - provisioning_api: 1.10.0
  - recommendations: 0.8.0
  - serverinfo: 1.10.0
  - settings: 1.2.0
  - sharebymail: 1.10.0
  - spreed: 10.0.7
  - support: 1.3.0
  - survey_client: 1.8.0
  - tasks: 0.13.6
  - text: 3.1.0
  - theming: 1.11.0
  - twofactor_backupcodes: 1.9.0
  - updatenotification: 1.10.0
  - user_status: 1.0.1
  - viewer: 1.4.0
  - weather_status: 1.0.0
  - workflowengine: 2.2.0
Disabled:
  - admin_audit
  - encryption
  - federation
  - firstrunwizard
  - systemtags
  - user_ldap

Nextcloud configuration:

{ "system": { "instanceid": "REMOVED SENSITIVE VALUE", "passwordsalt": "REMOVED SENSITIVE VALUE", "secret": "REMOVED SENSITIVE VALUE", "trusteddomains": [ "owncloud.reeves.one" ], "datadirectory": "REMOVED SENSITIVE VALUE", "overwrite.cli.url": "https:\/\/owncloud.reeves.one", "dbtype": "mysql", "version": "20.0.9.1", "dbname": "REMOVED SENSITIVE VALUE", "dbhost": "REMOVED SENSITIVE VALUE", "dbtableprefix": "oc", "dbuser": "REMOVED SENSITIVE VALUE", "dbpassword": "REMOVED SENSITIVE VALUE", "logtimezone": "UTC", "installed": true, "loglevel": "2", "forcessl": true, "theme": "", "maintenance": false, "mail_from_address": "REMOVED SENSITIVE VALUE", "mail_smtpmode": "sendmail", "mail_domain": "REMOVED SENSITIVE VALUE", "mail_smtpdebug": false, "mail_smtphost": "REMOVED SENSITIVE VALUE", "mail_smtpport": 25, "mail_smtptimeout": 10, "mail_smtpsecure": "", "mail_smtpauth": false, "mail_smtpauthtype": "LOGIN", "mail_smtpname": "REMOVED SENSITIVE VALUE", "mail_smtppassword": "REMOVED SENSITIVE VALUE", "default_language": "en", "log_rotate_size": 10485760, "check_for_working_htaccess": false, "preview_max_x": 512, "preview_max_y": 512, "preview_max_scale_factor": 1, "preview_max_filesize_image": 10, "enabledPreviewProviders": [ "OC\Preview\PNG", "OC\Preview\JPEG", "OC\Preview\GIF", "OC\Preview\HEIC", "OC\Preview\BMP", "OC\Preview\XBitmap", "OC\Preview\MP3", "OC\Preview\TXT", "OC\Preview\MarkDown", "OC\Preview\Krita" ], "openssl": { "config": "\/etc\/ssl\/openssl.cnf" }, "memcache.local": "\OC\Memcache\APCu", "filelocking.enabled": "true", "filelocking.ttl": 3600, "memcache.locking": "\OC\Memcache\Redis", "redis": { "host": "REMOVED SENSITIVE VALUE", "port": 0, "timeout": 1.5, "password": "REMOVED SENSITIVE VALUE", "dbindex": 1 }, "trashbin_retention_obligation": "auto", "enable_avatars": true, "allow_user_to_change_display_name": true, "check_for_working_wellknown_setup": false, "appstore.experimental.enabled": true, "updater.release.channel": "stable", "blacklisted_files": [] } }


**Are you using an external user-backend, if yes which one:** No

### Client configuration
**Browser:** FF

**Operating system:** Kubunut 18.04

### Logs

#### Nextcloud log (data/owncloud.log)

Only 2 entries, neither relevant


#### Browser log (all errors when loading dashboard)

activity-sidebar.js?v=c557ce13-1:603 Uncaught TypeError: Cannot read property 'extend' of undefined at activity-sidebar.js?v=c557ce13-1:603 at activity-sidebar.js?v=c557ce13-1:803 comments.js?v=c557ce13-1:1 Uncaught TypeError: Cannot read property 'extend' of undefined at comments.js?v=c557ce13-1:1 at Module. (comments.js?v=c557ce13-1:1) at n (comments.js?v=c557ce13-1:1) at comments.js?v=c557ce13-1:1 at comments.js?v=c557ce13-1:1 files_versions.js?v=c557ce13-1:1 Uncaught TypeError: Cannot read property 'extend' of undefined at Module. (files_versions.js?v=c557ce13-1:1) at n (files_versions.js?v=c557ce13-1:1) at files_versions.js?v=c557ce13-1:1 at files_versions.js?v=c557ce13-1:1 viewer-main.js?v=c557ce13-1:403 Please do NOT wait for the DOMContentLoaded before registering your viewer handler dashboard.js?v=c557ce13-1:87 GET https://owncloud.reeves.one/index.php/apps/mail/api/avatars/url/m.bariola%40gmail.com 404 dashboard.js?v=c557ce13-1:338 GET https://owncloud.reeves.one/ocs/v2.php/apps/user_status/api/v1/statuses/daniel 404 dashboard.js?v=c557ce13-1:338 GET https://owncloud.reeves.one/ocs/v2.php/apps/user_status/api/v1/statuses/enjell 404 dashboard.js?v=c557ce13-1:87 GET https://owncloud.reeves.one/index.php/apps/mail/api/avatars/url/streng-privat%40posteo.de 404 dashboard.js?v=c557ce13-1:87 GET https://owncloud.reeves.one/index.php/apps/mail/api/avatars/url/annemollenhauer%40yahoo.com 404 dashboard.js?v=c557ce13-1:87 GET https://owncloud.reeves.one/index.php/apps/mail/api/avatars/url/mlh.heiden%40gmail.com 404

nickvergessen commented 3 years ago

I guess it shows the icon and cancels it to load notifications-dark-new.svg instead of soemthing?

timreeves commented 3 years ago

Hi Nick,

thanks for the very prompt reply, this is what I see:

notifications-new.svg | (canceled) |   | notifications-main.js?v=c557ce13-1:7 | 0 B | 183 ms notifications | 200 | xhr | notifications-main.js?v=c557ce13-1:63 | 838 B | 17.93 s notifications.svg | 200 | svg+xml | main.js?v=c557ce13-1:1 | 643 B | 1.49 s

So yes, but well... Apparently, it loads the icon for new notifications, then does an XHR to see if there actually are any, finds there are not, and cancels the old request and fetches a 2nd icon, the one for no new notifications. All in the name of efficiency :) As if, on any reasonably fast server, the user could see the previous icon for any length of time. This really seems strange to me - why not put an empty little div there, do the XHR, and insert the appropriate icon into the div? The XHR will happen so or so, and so we eliminate one redundant request.

Thanks for pointing the way to look!  

nickvergessen commented 3 years ago

So part one is in https://github.com/nextcloud/notifications/pull/946

The other part is loading the first set of notifications with the page load as initial state data, but that's tracked in #264 and a lot more work.

timreeves commented 3 years ago

Thanks, Nick, for checking this out. So it looks like that may be improved at some time. But there are also 404 issues with the user_status (planned 404s, would you believe) and with the Mail App looking for Avatars of every email address on-page. Re the 1st it sounds like they don't want to change it and I would have to catch that location in webserver config; and Christoph Wurst has acknowledged the question in the Mail app but does not see it as a high priority to provide an option. So all in all it looks very much like I'll have to either catch all the locations, or give up on monitoring 404's in Fail2Ban. I reckon I'll go with the latter - inasmuch as many non-NC websites produce 404's anyway for missing images etc.

So for my part the heat is off on this topic. That said, I do vaguely remember the good old days when there was only ownCloud, and the thing was damn responsive. Now, the dashboard and many apps seem to be providing all things unto all men, and even with a fast server and my Gigabit internet connection, I'm waiting and watching as the dashboard page laboriously fills out. With the browser debugger open and watching all the requests happening and happening... Years ago I suggested a rewrite of the Contacts app to use infinite scrolling with XHR requests to the server. AFAIK it hasn't happened to date, and all the users contacts are sent to the FE and their display toggled in JS. The whole thing becomes unresponsive - at that time with well under 1.000 contacts, which some users do have...

In general, a JIT strategy could improve the responsiveness quite a lot, imho.

That said: I still love NC and use it with much gratitude. Many thanks!

Tim

nickvergessen commented 3 years ago

Yeah xou should not monitor 404s