-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: buf.copy is not a function #423
Comments
Yes, it is indeed an Engine.IO issue and it's something that we cannot fix from Primus as it's the part where it receives messages from the browser to the server. So it's not the |
ok, thanks. I let them know socketio/engine.io#356 |
@noamshemesh try to monkey patch engine.io and see what happens here https://github.com/socketio/engine.io/blob/a31551e141d3ea227e3f85b93285007ca16e4de0/lib/transports/polling.js#L160 Probably |
@lpinca thanks, that what we did. we saw that the client sends one big object to the client over pulling and then the server crashes. |
I tried reproducing this streaming a big file (~300MB) from client to server but it works fine. |
did you set our setup for primus client is:
|
I used the |
This is the code I'm using: 'use strict';
const Primus = require('primus');
const http = require('http');
const fs = require('fs');
const server = http.createServer();
const primus = new Primus(server, { transformer: 'engine.io' });
primus.on('connection', spark => {
console.log(spark.id, 'connected');
spark.on('end', () => primus.destroy());
spark.pipe(fs.createWriteStream(__dirname + '/copy.txt'));
});
primus.on('disconnection', spark => console.log(spark.id, 'disconnected'));
server.listen(3000, () => {
const socket = new primus.Socket('http://localhost:3000', {
websockets: false
});
fs.createReadStream(__dirname + '/300MB.txt', { encoding: 'utf8' })
.on('data', data => socket.write(data))
.on('end', () => socket.end());
}); |
seems like a slim version of what we do. we even write less data than 300mb. |
I wonder if it's a middleware or a plugin that causes the issue. |
we don't use any middleware for primus itself. we use only authorize to validate the connection. |
The same issue was happening when using the authorization middleware. I'll try adding that. |
interesting! waiting for updates |
Still no luck, I've added primus.authorize((req, next) => setTimeout(next, 50)); to the previous code, but it works. |
Hi,
we use primus 4.0.4 with engine.io 1.6.4 and node 4.2.4.
to stream data from db to client we use
spark.write()
.it works well for almost all the times but when there is a lot of data to stream it's crashing with this error:
after enabling DEBUG for engine.io pulling, we see these log lines:
I'm pretty sure that it's an engine.io problem, but maybe I wrong.
The text was updated successfully, but these errors were encountered: