joyent/node — pull request #4676 by isaacs (2013-01-28 19:19:19+00:00)
Title: net: Avoid tickDepth warnings on small writes

Stumbled upon this running a benchmark that was (incorrectly) doing a very small write in the callback of a very small write.

Since the write was small, it was entirely flushed, and the callback was called on nextTick by the Stream.Writable class (so as to prevent a "sometimes-sync" API).

However, the net.Socket class calls its `_write` callback synchronously when the chunk was entirely flushed, leading to a tickDepth warning.

Synchronous write streams can still trigger the tickDepth warning, but at least we should not cause this in net.Socket, and the alternative is a stack overflow. (Another alternative way to solve this would be for net.Socket to *always* defer its write cb, but that is giving up a significant optimization.)

Also, this exposes process.tickDepth as a read-only property, which is pretty useful.