partkeepr / PartKeepr

Open Source Inventory Management
http://www.partkeepr.org
GNU General Public License v3.0
1.38k stars 400 forks source link

Hardcoded 30s timeout for AJAX requests #914

Closed keton closed 6 years ago

keton commented 7 years ago

System Information

Critical Error

Details
==================================
The server returned a response which we were not able to interpret.

Request
==================================
GET https://partkeepr.hosting.com/api/grid_presets?_dc=1507551713694

Response Status Code
==================================
0

Response
==================================
undefined

Server Configuration
==================================
doctrine_orm_version: 2.5.4
doctrine_dbal_version: 2.5.2
doctrine_common_version: 2.6.0-DEV
php_version: 7.0.22-0ubuntu0.16.04.1
auto_start_session: true
maxUploadSize: 1073741824
isOctoPartAvailable: true
availableImageFormats: JPG,GIF,PNG
max_users: unlimited
authentication_provider: PartKeepr.Auth.HTTPBasicAuthenticationProvider
tip_of_the_day_uri: https://partkeepr.org/tips/%s
password_change: true
patreonStatus: [object Object]

How to reproduce

  1. Create partkeepr instance with many parts, descriptions and full octopart metadata (prices, images, datasheets, etc.). For me magical number was about 1k parts
  2. add some projects with many parts, about 100 projects should be enough
  3. try going into project reports. After 30s error message described above will appear

What's most likely going on

(correct me if I'm wrong, I don't know php/Symphony)

  1. Interesting fact - timeout always occurs after 30 seconds and originates from client side javascript code. This is clearly visible in browser developer tools (networking section)
  2. All paths requested project reports by AJAX calls render ok but it takes longer than 30s. Data seem to be valid JSON
  3. after some investigation I've discovered that ExtJS library used by partkeepr has hardcoded timeout for requests and it's equal to 30 seconds.
  4. I've hacked together a version of ext-all.js in partkeepr-1.3.0/web/js/packages/extjs6/build that has timeouts extended to 600 seconds and my partkeepr instance has started to work. For reference my current database takes about 45s to render in "Project reports" and most likely it will take longer as part list grows.

So would it be possible to configure ExtJS timeout somehow? I don't like idea of blindly patching library I don't know every time there's partkeepr update.

There is Ext.Ajax.setTimeout(timeout) function that should do just that but it has no effect when it's executed in javascript console of partkeepr interface.

Drachenkaetzchen commented 6 years ago

I have added a patch to increase the default timeout to 300 seconds to the latest GIT version.

To properly override the timeout, you can copy and paste the following JS snippet to your JS console:

Ext.define("PartKeepr.RestOverride", {
   override: 'PartKeepr.data.HydraProxy',

   timeout: 300000,
});