且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

NodeJS流暂停/恢复不适用于XMLHttpRequest,但适用于curl?

更新时间:2023-10-16 22:32:16

有点可以预见,这没有任何关系使用curl vs. XMLHttpRequest ,而是使用 serverRequest.pause 这一事实只是建议性的;它实际上并没有立即停止。也就是说,它几乎没用。

Somewhat predictably, this didn't have anything to do with curl vs. XMLHttpRequest, but instead with the fact that serverRequest.pause is only advisory; it doesn't actually pause right away. That is, it's pretty much useless.

所以大概在CURL的情况下,时间很好,暂停实际上按预期工作,而在 XMLHttpRequest 情况下,时间已关闭,其中一个来自外部 数据事件设法通过咨询暂停。

So presumably in the CURL case the timing was nice enough that pause actually worked as expected, whereas in the XMLHttpRequest case the timing was off, and one of the "from outside" data events managed to slip through the "advisory" pause.

在线程中讨论过显然有各种各样的修复,但是我对这整个流/缓冲区宇宙仍然很不稳定所以我不会尝试推荐在这个答案中有一个。

There are apparently various fixes for this, discussed in the thread, but I'm still pretty shaky on this whole streams/buffers universe so I won't try to recommend one in this answer.

我添加了暂停,假设它确实有效。

I've added a documentation pull request in the hopes nobody else tries to use pause assuming that it actually works.