Will request.pause() get fixed?

瀏覽次數:397 次
跳到第一則未讀訊息

Denis Washington

未讀,
2012年2月6日 中午12:11:132012/2/6
收件者:nod...@googlegroups.com
Hi,

I am trying to implement authenticated file upload, which means that I
want to check any request before reading in the POST body. As the
checking requires IO, though, I cannot (and don't want to) listen to the
request's 'data' event before the 'request' handler terminates.

Now I thought that request.pause() is just what I need, but sadly I
found out that it still leaves through some 'data' events. Here is the
thread from early 2011 that I found regarding that issue:

http://groups.google.com/group/nodejs/browse_thread/thread/cafe8397e3bec189

This doesn't seem to be fixed as of Node 0.6.10, so my question is:
*will* it be fixed? Or do I need to hack around that issue by buffering
the data that pause() lets through? I would rather not, and as I am
probably not the only one who would have to code up that exact
workaround, I think it is fair enough to say that this should be in Node
core.

Regards,
Denis Washington

Igor Zinkovsky

未讀,
2012年2月6日 下午2:01:362012/2/6
收件者:nodejs
I believe this was fixed in master (https://github.com/joyent/node/
commit/e6b6075024e9f1330575b10d7e6552e1ea6dad56), but will not be back-
ported to v0.6. Latest unstable build (v0.7.2) should contain the fix.

Denis Washington

未讀,
2012年2月6日 下午4:18:402012/2/6
收件者:nod...@googlegroups.com

It works in 0.7.2, thanks! I didn't see any mention in the release notes
on the Node blog.

Regards,
Denis

tjholowaychuk

未讀,
2012年2月6日 下午5:55:222012/2/6
收件者:nodejs
oh yay! finally! haha

Mikeal Rogers

未讀,
2012年2月6日 晚上9:05:252012/2/6
收件者:nod...@googlegroups.com
This really needs to be fixed in Stream.pipe() as well.

The fact that we insure this for http.ServerRequest and nowhere else is not good.

We also need to get pause() to take a size argument for how large it should allow the buffer to get before it causes the remote end to stop sending data. This has all been discussed and more or less approved in pull requests that weren't finished.

It would be great if, for 0.8, we could get Stream.pause(size) implemented/fixed and make it consistent across all of node.

-Mikeal

> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Mophy Xiong

未讀,
2012年2月6日 晚上11:55:492012/2/6
收件者:nodejs
We really think such bug fixes should be ported to CURRENT STABLE
build, before the newly stable version is out. Because people are not
recommended to work on unstable builds for productions, but current
stable wouldn't get fixed. Then all we can do is wait? :-) Well, if
the porting is tough due to differences between 0.7 and 0.6, then
forget this ;-)


Regards,
Mophy

Mikeal Rogers

未讀,
2012年2月7日 凌晨1:47:052012/2/7
收件者:nod...@googlegroups.com
This is not a bugfix, IMO, it's a feature. A feature we all want, a feature that fixes something newcomers trip on often, but previous released *intended* for the behavior to be the way it was and we have now changed it because this new way is better.

It's a feature, it won't be backported.

Mophy Xiong

未讀,
2012年2月7日 凌晨2:08:282012/2/7
收件者:nodejs
Well, if this is not treated as a bugfix, it makes sense not
backporting it.

Regards,
Mophy

Bert Belder

未讀,
2012年2月7日 清晨6:09:112012/2/7
收件者:nodejs
On Feb 7, 7:47 am, Mikeal Rogers <mikeal.rog...@gmail.com> wrote:
> This is not a bugfix, IMO, it's a feature. A feature we all want, a feature that fixes something newcomers trip on often, but previous released *intended* for the behavior to be the way it was and we have now changed it because this new way is better.
>
> It's a feature, it won't be backported.

I would like to *guarantee* that pause() pauses immediately in node
0.8. Most of the time it pauses immediately anyway, and it's a huge
PITA dealing with the remaining edge cases where a data event might
happen after a pause() call. If people really like the old situation
we could make the old behavior optional, e.g.
`stream.pause(allowData=false)`.

Isaac Schlueter

未讀,
2012年2月7日 上午11:20:292012/2/7
收件者:nod...@googlegroups.com
On Tue, Feb 7, 2012 at 03:09, Bert Belder <bertb...@gmail.com> wrote:
> If people really like the old situation
> we could make the old behavior optional, e.g.
> `stream.pause(allowData=false)`.

No one wants the old behavior. It's only confusing.

We do need to put some kind of limit on how much will be buffered,
however. It's too easy to pause a request, then fail to resume it in
a reasonable time, and have it take up all the memory. This won't
happen very often when dealing with TCP streams, since they'll push
back on the wire, but if we make this a general guarantee on userland
streams, then it needs to be implemented in Stream.stream, and take an
argument for how many bytes to buffer.

stream.pause(maxBuffer=1024) or something. Then keep an array of
chunks (like Koichi did for http request streams), and if the total
length goes over that number, then start emitting data events. This
will impact performance a bit when it happens, but since it's a
relatively rare situation, I think that's probably fine.

Mikeal Rogers

未讀,
2012年2月7日 下午1:46:052012/2/7
收件者:nod...@googlegroups.com
What you mean by "pause" is not what node meant as "pause" in the past. In the past, pause meant "send a signal to the input stream to stop sending me data", that did not insure that data that was enroute wasn't still going to be emitted.

From a high level, your vision of "pause" makes a lot more sense, especially to people that aren't hardcore network geeks like half of the people who work on core :), and that's why there is no resistance whatsoever to fixing core to be pause(maxSize) BUT this is a semantic change and is considered a *feature* and will not be backported, nor would we accept the change a bugfix release because there may be some hidden potential for bugs that assume the old behavior.

-Mikeal

Will Wen Gunn

未讀,
2012年2月8日 凌晨12:36:412012/2/8
收件者:nod...@googlegroups.com
The bug  has been fixed on v0.7.0.
回覆所有人
回覆作者
轉寄
0 則新訊息