jcoglan/faye — Issue #106: Server-side Faye crashes with exception
Author: alexkazeko
Created: 2011-10-25 08:48:59+00:00
State: open

Hi,

I'm running faye on node and once per day or week it dies with this exception:

```
http.js:602
throw new TypeError('first argument must be a string, Array, or Buffer');
^
TypeError: first argument must be a string, Array, or Buffer
at ServerResponse.write (http.js:602:11)
at /var/.../public/faye-node.js:2573:18
at /var/.../public/faye-node.js:2561:7
at [object Object]. (fs.js:80:5)
at [object Object].emit (events.js:64:17)
at fs.js:820:12
```

The code around this line:

```
handle: function(request, response) {
var requestUrl = url.parse(request.url, true),
requestMethod = request.method,
self = this;

if (/\.js$/.test(requestUrl.pathname))
return this.loadClientScript(function(content) {
response.writeHead(200, self.TYPE_SCRIPT);
response.write(content);
response.end();
});

if (requestMethod === 'OPTIONS')
return this._handleOptions(request, response);
```

It fails on **response.write(content);**

BTW, i've found in trace this method: loadClientScript:. But client-side faye.js is loaded from another server, so it looks like that:

``
. . .
`client = new Faye.Client("http://app.mysite.com:42000/faye");`

I've seen this topic - https://github.com/jcoglan/faye/issues/37 - but seems like it a very old code and not really related.

Any ideas what's going on?