joyent/node — Issue #2263: XMLHttpRequest piped in a writable file stream hangs next request
Author: gabipetrovay
Created: 2011-12-04 05:26:02+00:00
State: open

Hi,

This is the thread where I came across this problem:
http://groups.google.com/group/nodejs/browse_thread/thread/5691a9fd25a6a65d

In that thread there was also another bug of mine but now I managed to minimize the remaining problem here:
http://dl.dropbox.com/u/2161705/test.zip

1. Run the test app and open http://localhost.com:3000/test.html in your browser.
2. An alert should tell you that an XMLHttpRequest POST request was made in the background.
3. Click the Reload link and the page should hang (2 minutes in Chrome or Firefox)

I also paste the code here if somebody can directly see a flaw in it:

app.js

```
var express = require('express');

var app = module.exports = express.createServer();

app.configure(function(){
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});

app.post('/test', function(req, res) {
var fs = require('fs');
var fileStream = fs.createWriteStream('./test.txt');

req.on('end', function() {
res.send(200);
});
req.pipe(fileStream);
});

app.listen(3000);
```

test.html

```

Reload (This will only work every second click)

```

Gabriel