File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -354,9 +354,12 @@ function clearSocketQueue(queue, socket) {
354354}
355355
356356function connectNextSocket ( ) {
357- isConnectionBusy = false ;
358- if ( connectionSocketQueue . length > 0 )
359- startConnection ( connectionSocketQueue [ 0 ] ) ;
357+ setTimeout ( function ( ) {
358+ isConnectionBusy = false ;
359+ if ( connectionSocketQueue . length > 0 ) {
360+ startConnection ( connectionSocketQueue [ 0 ] ) ;
361+ }
362+ } , 1 ) ;
360363}
361364
362365function interruptConnection ( socket , note , user ) {
@@ -693,8 +696,11 @@ function operationCallback(socket, operation) {
693696 }
694697 note . tempUsers [ userId ] = Date . now ( ) ;
695698 }
696- // save authorship
697- note . authorship = models . Note . updateAuthorshipByOperation ( operation , userId , note . authorship ) ;
699+ // save authorship - use timer here because it's an O(n) complexity algorithm
700+ setImmediate ( function ( ) {
701+ note . authorship = models . Note . updateAuthorshipByOperation ( operation , userId , note . authorship ) ;
702+ } ) ;
703+ }
698704
699705function updateHistory ( userId , note , time ) {
700706 var noteId = note . alias ? note . alias : LZString . compressToBase64 ( note . id ) ;
You can’t perform that action at this time.
0 commit comments