Skip to content

Instantly share code, notes, and snippets.

View csosborn's full-sized avatar

Chris Osborn csosborn

  • Facebook Reality Labs
  • New York
View GitHub Profile
@csosborn
csosborn / toosoon.js
Created January 10, 2012 17:27
illustration of timer-related event loop problem in Node.js 0.6
var i = 0;
// complain loudly if node exits before this handler is removed
var onExit = function() {
console.log('Exiting prematurely! (after %s iterations)', i);
};
process.on('exit', onExit);
function doIteration() {
@csosborn
csosborn / tls_bug.js
Created June 24, 2011 15:43
demonstration of stream-related bug in tls.js
/*
Demonstration of apparent bug in tls.js. When piping a readable file stream into a writable
TLS stream (an https ClientRequest) the TLS stream write() method returns false, causing
the readable stream to pause, then never emits a drain event. The readable stream thus
remains paused and the transfer hangs.
*/
var https = require('https');
var http = require('http');
var fs = require('fs');