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

Gitea doesn't open more than 5 tabs in browser #11978

Closed
2 of 7 tasks
lakostin opened this issue Jun 19, 2020 · 28 comments · Fixed by #12095
Closed
2 of 7 tasks

Gitea doesn't open more than 5 tabs in browser #11978

lakostin opened this issue Jun 19, 2020 · 28 comments · Fixed by #12095
Labels
Milestone

Comments

@lakostin
Copy link

lakostin commented Jun 19, 2020

  • Gitea version (or commit ref):
    1.12.0
  • Git version:
    2.17.1
  • Operating system:
    Ubuntu 18.04.3 LTS
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I open pull request with multiple commits, then i open 5 new tabs in browser with each commit. Everything is ok. When i open the sixth tab and further they hang with message "Waiting for available socket..." until i close one of the previously opened tabs.
It can be reproduced in any browser.
What can this be connected to?

Screenshots

@lunny
Copy link
Member

lunny commented Jun 19, 2020

can't reproduce in https://gitea.com

@lunny lunny added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jun 19, 2020
@lakostin
Copy link
Author

Updated description.

@wkobiela
Copy link

@lakostin
Just checked myself, Gitea 1.12.0, GIT 2.26.2, MySQL, hosted on Synology.
Created PR with >5 commits, opened PR and each commit multiple times. No issues.

@lakostin
Copy link
Author

lakostin commented Jun 19, 2020

I have this isssue on multiple instances and even on different versions. All served by docker btw

@chxseh
Copy link

chxseh commented Jun 19, 2020

Can confirm, opening any new tabs after 6 have loaded for me results in awaiting for socket. Hosting on Docker as well.

@dexterxx-pl
Copy link

I had same issue here, just after updating to v1.12.
It's not related just to PR's - in my case I've just opened new tabs of issues of my project - loading just stucks... and it stucks for many minutes.

CPU usage stays at typical level, logs shows that database (MySQL in my case) also respond in typical time.

Now I've just figured out, that restarting gitea didn't solved problem, but restarting proxy (apache2) does.

After restarting I cannot now reproduce it 👎

@lakostin are you using proxy at front of gitea?

@chxseh
Copy link

chxseh commented Jun 19, 2020

@dexterxx-pl Tried restarting my proxy in front of gitea to no effect.

@lafriks
Copy link
Member

lafriks commented Jun 20, 2020

I think it is related to events endpoint that uses sockets for getting events about new notifications. We should probably somehow limit sockets count per user probably

@deptyped
Copy link

deptyped commented Jun 20, 2020

Same problem. But I could not reproduce this issue without a reverse proxy server (nginx in my case).
By the way, in Firefox pages stop loading after five clicks on the site in one tab.

UPD: Using http2 in nginx solved the problem

@zeripath
Copy link
Contributor

Yeah I suspect this is EventSource issues.

@zeripath
Copy link
Contributor

So I don't think this is the server holding things up but rather the browser. It looks like Firefox is blocking instead of just failing out.

@confusedsushi
Copy link
Contributor

I can confirm this. It happened first after upgrading to 1.12. I am running gitea on Windows 10 2004 with an apache reverse proxy on Ubuntu 18.04.

I am able to reproduce this with Firefox and Chrome.

@lafriks lafriks added type/bug and removed issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Jun 21, 2020
@zeripath
Copy link
Contributor

Can anyone reproduce this on try?

@Governa
Copy link

Governa commented Jun 22, 2020

Can anyone reproduce this on try?

It seems I do. Both in Firefox and in Chromium.

I just have to Login and from the Dashboard open multiple commits in tabs. If then I click on "View source" it will not load until I close enough(about 5 tabs are left open) tabs.

It seems to be about 5 tabs in each browser, as I could test Chromium while Firefox tabs were still open.

@lakostin
Copy link
Author

Reproduced also in Gitea Version: 1.12.1 running with systemd.
Do not use any proxy server in front.

@flozzone
Copy link
Contributor

Also Reproducible

version: 1.12.1
proxy: apache 2.4
env: docker container

  • 5-6 clicks and gitea hangs, but when I open a private window and login, gitea works and is accessible again.
  • Then I tried to reproduce this issue within a private window -> no chance
  • Its interesting that in the debugger inside a private window I can see connections to /user/events (See the curl cmd below) while navigating, but not within a regular browser tab
  • When doing the last click, no communications occur (Checked proxy access logs)

curl 'https://GITEA_HOST/user/events' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0' -H 'Accept: text/event-stream' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Cookie: lang=en-US; i_like_gitea=33dxxxxxxxxx270; _csrf=zIz1_5HrJzMfqWC4XXXXXXXXXXXXXXXXXXXXXOTQyNw' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'

@mind-overflow
Copy link

mind-overflow commented Jun 24, 2020

This also happens while normally browsing Gitea, you do not need to open 5 different tabs at the same time. I have ran into this problem just by navigating through my commits and repository files, and have been running into it since at least version 1.11. I am now using 1.12.1 with the same identical problem.

Gitea is running behind an Apache2 reverse proxy, no docker. MySQL database. Ubuntu 20.04 LTS.

@42wim
Copy link
Member

42wim commented Jun 25, 2020

I can also reproduce this (on gitea 1.12.1), the /user/events keep pending.
Related to https://developer.mozilla.org/en-US/docs/Web/API/EventSource and HTTP/2.

I've patched my own gitea to disable javascript going to /user/events and everythings works fine now.
There should be an option to disable this when people don't have access to HTTP/2 loadbalancers.

@lunny lunny added this to the 1.12.2 milestone Jun 26, 2020
@westhom
Copy link

westhom commented Jun 27, 2020

I was seeing this issue in Firefox / Gitea 1.12.1, clicking around gitea a bunch would eventually cause requests to hang and never complete, essentially freezing the app. I noticed in the network debugger a lot of the requests were being fulfilled by the Service Worker.

I was able to fix my issue by going into about:debugging and unregistering the service worker for my gitea domain, then refreshing the tab. Now I can't reproduce the issue. The service worker appeared in the list after I re-opened for the first time, but all seems good now.

@ratuka
Copy link

ratuka commented Jun 29, 2020

Same here with Firefox and Chrome too.

@zeripath
Copy link
Contributor

zeripath commented Jun 29, 2020

Sorry about this. This one is my fault.

There is a workaround:

[ui.notification]
EVENT_SOURCE_UPDATE_TIME=0

or use HTTP/2.0.

I've finally managed to hack up a fix and will push up a PR to push the EventSource stuff into a SharedWorker but it will need review.


Unfortunately the setting doesn't work due to a misunderstanding on my behalf. My suspicion was the EventSource would not open if you hit the tab limit not - that it would prevent opening new tabs - and although I tested with opening multiple tabs it didn't cause these problems.

This code has been part of master for quite some time - I don't understand why it was only on release of Gitea 1.12 that this problem was noticed. Presumably try runs on HTTP/2.0?

@mind-overflow
Copy link

mind-overflow commented Jun 29, 2020

Sorry about this. This one is my fault.

There are two workarounds:

[ui.notification]
EVENT_SOURCE_UPDATE_TIME=0

or use HTTP/2.0.

I've finally managed to hack up a fix and will push up a PR to push the EventSource stuff into a SharedWorker but it will need review.

EDIT: Looks like Firefox had cached some settings. I was still using HTTP 1.1 with my old session, however in incognito mode (and thus clearing the cookies too) switched me to HTTP 2.0, fixing the problem.

Very weird, since my server allows HTTP 2.0 connections and I still manage to have this issue... Are you sure about the second fix? I'm starting to doubt that my configuration could be faulty, even though the Firefox dev console says I'm using HTTP 2.0...

@chxseh
Copy link

chxseh commented Jun 29, 2020

[ui.notification]
EVENT_SOURCE_UPDATE_TIME=0

Doesn't appear to work for me, not sure if I just did something wrong.. Will try and figure out switching to HTTP/2.0.

zeripath added a commit to zeripath/gitea that referenced this issue Jun 30, 2020
Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.
Also adds several options to control this.

Fix go-gitea#11978

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor

@ChaseHall try -1 instead of 0?

@chxseh
Copy link

chxseh commented Jun 30, 2020

@zeripath -1 just results in a 503. Nothing useful in docker logs about it..

@42wim
Copy link
Member

42wim commented Jun 30, 2020

I can second that, same issues as @ChaseHall

@zeripath
Copy link
Contributor

@ChaseHall @42wim - sorry you're right - that's another bug with this too. 😞

@zeripath
Copy link
Contributor

OK #12095 will fix that too. Setting EVENT_SOURCE_UPDATE_TIME=-1 will disable all EventSources from that point.

zeripath added a commit that referenced this issue Jul 3, 2020
Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.

Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating

Fix #11978

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
zeripath added a commit to zeripath/gitea that referenced this issue Jul 3, 2020
Backport go-gitea#12095

Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.

Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating

Fix go-gitea#11978

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
lafriks pushed a commit that referenced this issue Jul 4, 2020
* Move EventSource to SharedWorker (#12095)

Backport #12095

Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.

Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating

Fix #11978

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>

* Bugfix for shared event source

For some reason our eslint configuration is not working correctly
and a bug has become apparent when trying to backport this to 1.12.

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Re-fix #12095 again

Unfortunately some of the suggested changes to #12095 introduced
bugs which due to caching behaviour of sharedworkers were not caught
on simple tests.

These are as follows:

* Changing from simple for loop to use includes here:

```js
  register(port) {
    if (!this.clients.includes(port)) return;

    this.clients.push(port);

    port.postMessage({
      type: 'status',
      message: `registered to ${this.url}`,
    });
  }
```

The additional `!` prevents any clients from being added and should
read:

```js
    if (this.clients.includes(port)) return;
```

* Dropping the use of jQuery `$(...)` selection and using DOM
`querySelector` here:

```js
async function receiveUpdateCount(event) {
  try {
    const data = JSON.parse(event.data);

    const notificationCount = document.querySelector('.notification_count');
    if (data.Count > 0) {
      notificationCount.classList.remove('hidden');
    } else {
      notificationCount.classList.add('hidden');
    }

    notificationCount.text() = `${data.Count}`;
    await updateNotificationTable();
  } catch (error) {
    console.error(error, event);
  }
}
```

Requires that `notificationCount.text()` be changed to use `textContent`
instead.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
ydelafollye pushed a commit to ydelafollye/gitea that referenced this issue Jul 31, 2020
Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.

Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating

Fix go-gitea#11978

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.