зеркало из https://github.com/mozilla/makedrive.git
Fix issues #72 - Callback already called
This commit is contained in:
Родитель
6def40f44e
Коммит
05fc29a8bc
|
@ -61,8 +61,8 @@ function handleRequest(data, fs, syncObject, syncSession, socket, callback) {
|
|||
// UPSTREAM - DIFFS
|
||||
handleDiffRequest();
|
||||
} else {
|
||||
syncObject.state = sync.SYNC_ERROR;
|
||||
syncObject.emit('error', new Error(data.content));
|
||||
syncObject.state = syncObject.SYNC_ERROR;
|
||||
syncObject.emit('error', data.content);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ function init(url, token, sync, fs, callback) {
|
|||
}
|
||||
|
||||
function handleClose(code, data) {
|
||||
if(data) {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch(e) {
|
||||
|
@ -84,6 +85,9 @@ function init(url, token, sync, fs, callback) {
|
|||
sync.state = sync.SYNC_DISCONNECTED;
|
||||
return sync.emit('disconnected');
|
||||
}
|
||||
} else {
|
||||
data = 'Websocket unexpectedly closed.';
|
||||
}
|
||||
|
||||
socket.close();
|
||||
var error = new Error(code + ': ' + data);
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = function( server ) {
|
|||
var sync = Sync.create( authData.username, authData.sessionId );
|
||||
sync.setSocket( ws );
|
||||
|
||||
ws.on('close', sync.onClose);
|
||||
ws.on('close', sync.onClose());
|
||||
|
||||
ws.on('message', function(data, flags) {
|
||||
if(!flags || (flags && !flags.binary)) {
|
||||
|
|
|
@ -76,6 +76,7 @@ function handleRequest(data) {
|
|||
that.init();
|
||||
} else {
|
||||
response = SyncMessage.error.locked;
|
||||
response.content = { error: "Current sync in progress! Try again later!" };
|
||||
}
|
||||
that.socket.send(response.stringify());
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче