【发布时间】:2020-06-27 01:37:51
【问题描述】:
我正在尝试制作进度条来监控 Tesseract.recognize() 调用,但是当我尝试发送更新以更改进度条时,我收到此错误:
[ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
这是在 routes.js 文件中运行的内容:
Tesseract.recognize(
'/app/'+statistic.path_out_new
,'eng'
, { logger: m => {
console.log(m);
res.render('pages/uploadPicture.ejs', {
user : req.user
,progress : m
});
} }
)
.then(({ data: { text } }) => {
res.render('pages/uploadPage.ejs', {
user : req.user
,progress : text
});
});
这里是来自 EJS 模板的 HTML 的相关部分,uploadPage.ejs:
<section><div></div><progress value="<%=progress.progress%>" text="<%=progress.status%>" /></section>
我已阅读this question 并且我认为问题是由于每次进度条有更新时发送多个标题引起的,但是我如何向用户发送有关函数如何进行的信息(以便进度条更新)也没有发送标题?我按照here 的建议尝试了 res.write() ,但这让进度条页面超时,而不是更新。
【问题讨论】:
-
您好,您能对我的回答提供一些反馈吗?
标签: javascript node.js express progress-bar tesseract.js