inbo / reporting-rshiny-grofwildjacht

Rshiny app for grofwildjacht
https://grofwildjacht.inbo.be/
MIT License
1 stars 1 forks source link

[BUG] Shinapp.js throws error #464

Closed SanderDevisscher closed 2 months ago

SanderDevisscher commented 5 months ago

Describe the bug When starting the app on PRD while viewing it using devtools I see the following error: image

it refers to this line of code in shinyapp.js:

      if (!/\/$/.test(defaultPath))
        defaultPath += '/';
      defaultPath += 'websocket/';

      var ws = new WebSocket(protocol + '//' + window.location.host + defaultPath);
      ws.binaryType = 'arraybuffer';

      return ws;
    };

To Reproduce Steps to reproduce the behavior:

  1. Go to 'faunabeheer.inbo.be'
  2. Click on 'F12'
  3. Click on 'Network'
  4. Wait
  5. See error

Expected behavior App loads without errors nor timeouts

Screenshots image

Additional context Deployment on UAT and PRD with the same hash works just fine when the internet connection is not throttled. Whenever the connection gets throttled ea 'fast 3G' the error occurs. If needed, because of issues with shinyproxy, please include Tobia!

Please give me a signal when you did your investigations so I can ask to revert to the previous hash.

Git SHA (after 0.3.1) 253e3d65227d4da71cb306553e5c2eb126dbf1d0

SanderDevisscher commented 5 months ago

Googling the issue led me to this https://github.com/openanalytics/shinyproxy/issues/222 🤔

mvarewyck commented 5 months ago

@SanderDevisscher I can reproduce locally but only when inspecting (F12) the Network. Do you know whether this issue was also present in earlier versions of the app?

LEDfan commented 5 months ago

Hi Sander

When did this problem start occurring? E.g. did you first notice this after an update of the app?

In any case, this could be an issue in ShinyProxy, when a (relatively) big amount of data is send over the websocket connection, e.g. when having a lot of plots. The good news is that this has been fixed in ShinyProxy in 12/2020, but it seems that you are running a version of ShinyProxy released in 2019. So it could be worth trying to update and hopefully this is issue is then fixed.

SanderDevisscher commented 5 months ago

@LEDfan There have been some issues with timeouts for some time now but I've just recently learned about chrome devtools which enabled me to detect the issue. @LEDfan can you take the necessary steps to update the shinyproxy ? If necessary please contact @TheJenne18 (Jens)! Since I have no access to the shinyproxy repository.

LEDfan commented 5 months ago

Okay, then I think it makes sense to try to update. I created a PR here: https://github.com/inbo/shinyproxy/pull/4 , this just a small upgrade, so not using the latest ShinyProxy release. But since I don't have access to AWS or really know how this deployment works, I cannot test or deploy the change. Let me know if you run into issues.

SanderDevisscher commented 5 months ago

@TheJenne18 can you take a look at the PR from @LEDfan ? Maybe deploy it to the UAT first so I can check whether the issue persists.

TheJenne18 commented 5 months ago

For uat we use the following repo's where we use other shintyproxy versions: https://github.com/inbo/shinyproxy-wbe/blob/uat/install_shinyproxy.sh#L14 https://github.com/inbo/shinyproxyV3/blob/main/install_shinyproxy.sh#L13

SanderDevisscher commented 5 months ago

@LEDfan can you check if the error also exists in these versions ? ifso can you fix it ?

SanderDevisscher commented 5 months ago

@TheJenne18 do we use the same shinyproxies for the PRD ?

LEDfan commented 5 months ago

@SanderDevisscher what is the URL for the UAT version of this app?

SanderDevisscher commented 5 months ago

faunabeheer-dev.inbo.be

LEDfan commented 5 months ago

Okay, I'm unable to reproduce it on https://faunabeheer-dev.inbo.be after numerous test. Which throttle settings do you use on faunabeheer-dev.inbo.be in order to reproduce the problem?

SanderDevisscher commented 5 months ago

@LEDfan I'm currently also unable recreate the initial issue. However I'm experiencing a timeout on both UAT & PRD when using any throttle (fast 3G and slower). @mvarewyck initial loading goes fast and then it stalls on the first map & related graphs.

I do get these errors when loading faunabeheer.inbo.be using fast 3G throttle: image

When loading faunabeheer-dev.inbo.be using fast 3G throttle I get: image

both errors take a while to manifest.

SanderDevisscher commented 5 months ago

hmm something strange is going on, 10min ago I was unable to recreate the issue. Now 20h43 after running it on my private account (without using devtools & no throttling) I get the error all the time on both private and work accounts. Clearing the cookies seems to fix the issue for a while.

mvarewyck commented 5 months ago

For me, the PRD website works in Firefox but not in Chrome. Could the Websocket error be this issue? Is PRD running a different version of Shinyproxy than UAT (that could help me to understand why it doesn't fail on UAT)

SanderDevisscher commented 4 months ago

@TheJenne18 can you answer @mvarewyck ?

SanderDevisscher commented 3 months ago

For me, the PRD website works in Firefox but not in Chrome. Could the Websocket error be this issue? Is PRD running a different version of Shinyproxy than UAT (that could help me to understand why it doesn't fail on UAT)

@TheJenne18 tells me currently UAT is running v3 while PRD is still running v2.3

mvarewyck commented 3 months ago

For me, the PRD website works in Firefox but not in Chrome. Could the Websocket error be this issue? Is PRD running a different version of Shinyproxy than UAT (that could help me to understand why it doesn't fail on UAT)

@TheJenne18 tells me currently UAT is running v3 while PRD is still running v2.3

This throttle issue was indeed fixed since ShinyProxy 2.4.2

SanderDevisscher commented 3 months ago

@TheJenne18 is deploying shinyproxy 2.5.1. to PRD. Deploying to v3 is more complex.

SanderDevisscher commented 3 months ago

@mvarewyck @LEDfan when looking at the waterfall on firefox1 I notice plotly-latest.min.js to be the largest time consumer (>1min). The app is also noticeably faster on firefox then chrome (where it still crashes when throttled).

1while loading v0.3.4. in PRD with shinyproxy v2.5.1 and throttled to "good 2G". "No throttle firefox": 388ms | "Good 3G firefox": 18s | "No throttle chrome": 678ms | "Fast 3G chrome": 23.5s causes timeout

mvarewyck commented 3 months ago

To investigate: https://plotly-r.com/performance

mvarewyck commented 2 months ago

@mvarewyck @LEDfan when looking at the waterfall on firefox1 I notice plotly-latest.min.js to be the largest time consumer (>1min). The app is also noticeably faster on firefox then chrome (where it still crashes when throttled).

I throttled the app on Chrome, but didn't result in a timeout. Wrt plotly-latest.min.js it is a file that is served from local server: clicking on the file we can see the source is localhost.

Screenshot from 2024-07-09 17-14-26

@SanderDevisscher Do you think we should further investigate on this or wait for the restructuring

SanderDevisscher commented 2 months ago

@mvarewyck I got news the app now loads even with less favorable internet connections. So I would suggest waiting until after the restructure.