处理Durandal应用程序中视图的加载超时 [英] Handling load timeouts of a view in a Durandal app
问题描述
我有一个Durandal应用程序,在尝试加载视图时会定期超时。这是一个示例超时错误:
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:
- 列出的模块中的脚本错误
- 路径配置不正确
- 多个模块ID映射到同一个文件
这些都不是我的问题。这是一个真实的,真正的超时。由于某种原因,它无法加载视图文件。
None of these are my issue. It is a real, genuine timeout. For some reason it wasn't able to load the view file.
有一些有关处理错误的RequireJS文档 ...但在阅读了很多次之后,我仍然无法弄清楚如何在我的视图模块上捕获加载超时。
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.
理想情况下,我想做的是a)延长超时或b)给用户一个通知并允许他们再次尝试加载视图。
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.
现在发生的事情是视图无法加载,用户没有得到错误的反馈 - 请等待,加载对话框消失,因为AJAX请求已完成,但视图没有改变。
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.
推荐答案
我有时遇到同样的问题。对我来说,它通常发生在另一个异步请求阻塞服务器时(在我的开发机器上一次只能处理一个请求)并且请求了一个视图。
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
});
这篇关于处理Durandal应用程序中视图的加载超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!