Permalink
Browse files

streams2: Wait until nextTick to call readStop

  • Loading branch information...
1 parent 948dcba commit e5e7a34122e18df36236f5684e72cb7571e617c8 @isaacs committed Dec 10, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/net.js
View
14 lib/net.js
@@ -463,11 +463,15 @@ function onread(buffer, offset, length) {
self._readableState.onread(null, buffer.slice(offset, end));
if (handle.reading && !self._readableState.reading) {
- handle.reading = false;
- debug('readStop');
- var r = handle.readStop();
- if (r)
- self._destroy(errnoException(errno, 'read'));
+ process.nextTick(function() {
+ if (handle.reading && !self._readableState.reading) {
+ handle.reading = false;
+ debug('readStop');
+ var r = handle.readStop();
+ if (r)
+ self._destroy(errnoException(errno, 'read'));
+ }
+ });
}
// Optimization: emit the original buffer with end points

0 comments on commit e5e7a34

Please sign in to comment.