Handling load timeouts of a view in a Durandal app

五迷三道 提交于 2020-01-04 03:30:12

问题


I've got a Durandal app that will periodically timeout when attempting to load a view. Here's an example timeout error:

Error: Load timeout for modules: text!views/primaryapplicants.html
http://requirejs.org/docs/errors.html#timeout

If you lookup the provided URL, it suggests a few possible issues:

  • Script error in listed module
  • Path configuration incorrect
  • Multiple module IDs map to the same file

None of these are my issue. It is a real, genuine timeout. For some reason it wasn't able to load the view file.

There is some RequireJS documentation on handling errors... but after reading it a number of times, I still can't figure out how to trap for a load timeout on my view module.

Ideally, what I would like to do is either a) extend the timeout or b) give the user a notification and allow them to try loading the view again.

What's happening right now is that the view simply fails to load and the user gets no feedback that there was an error--the "please wait, loading" dialog disappears because the AJAX request finished, but the view doesn't change.


回答1:


I sometimes have the same issue. For me, it usually happens when another asynchronous request is blocking the server (that can handle only one request at a time on my dev machine) and a view is requested.

I don't know yet how to catch this, but in order to increase/disable the timeout:

requirejs.config({
    waitSeconds: 0 // 0 disables the timeout completely, default is 7 seconds
});


来源:https://stackoverflow.com/questions/19431164/handling-load-timeouts-of-a-view-in-a-durandal-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!