I have a web app that does backend-asynchronous REST calls.
(我有一个Web应用程序,可以执行后端异步REST调用。)
When I say backend-asynchronous REST calls what I mean is that the backend receives the REST call and replies to it on a different thread (it uses a queue and a thread pool...). (当我说后端异步REST调用时,我的意思是后端接收REST调用并在另一个线程上对其进行回复(它使用队列和线程池...)。)
All of this seems to be working fine. (所有这些似乎都工作正常。)
I do a GET from JavaScript to get new HTML pages so that I can process it before it gets added to the DOM.
(我从JavaScript进行GET获取新的HTML页面,以便可以在将其添加到DOM之前对其进行处理。)
I am using the following code to get the HTML pages: (我正在使用以下代码来获取HTML页面:)
static async getHTML( url, callback ) {
let response;
try {
response = await fetch(url, { // AAA
method: 'GET',
headers: {
'Content-type': 'text/plain'
}
});
let y = 1; // BBB
} catch (err) {
let x = 1;
}
try {
let r = await response.text();
callback(r);
} catch (err) {
let z = 1;
}
}
The first time I use getHTML, it works fine.
(第一次使用getHTML时,效果很好。)
I then call a REST service and have verified that it is completing before I call getHTML the second time. (然后,我调用REST服务,并在第二次调用getHTML之前已验证它已完成。)
The second time I call getHTML, it takes 14 seconds to go from AAA to BBB on a local server. (第二次调用getHTML时,在本地服务器上从AAA到BBB花费14秒。)
If I eliminate the REST call, the second call to getHTML is instantaneous.
(如果我取消了REST调用,则第二次调用getHTML是瞬时的。)
So, something about the REST call is causing getHTML's fetch to take 14 seconds. (因此,有关REST调用的某些操作导致getHTML的提取需要14秒钟。)
Again, I have verified that the REST call is completing before I am calling getHTML. (同样,在调用getHTML之前,我已验证REST调用已完成。)
Any help on why this is now taking 14 seconds is greatly appreciated.
(非常感谢您对为什么现在需要14秒的任何帮助。)
Blake McBride
(布莱克·麦克布莱德)
ask by Blake McBride translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…