jsondiffpatch icon indicating copy to clipboard operation
jsondiffpatch copied to clipboard

Seems not be thread safe

Open maxiplay opened this issue 5 years ago • 0 comments

Thanks for you fantastic library. It help me a lot :) I used it to implement an incremental saving system of books in my app => writecontrol.fr

The idea is to just send the diffs between front and backend when writting a book. So I used your script browser side to generate diff and backend side to apply diff :)

It worked good until now when I reached a certain number of user simultaneously. (60)

I'm using java nashorn to execute jsondiffpatch in java server.

The function that apply the diff server side is

function patch(){ 
                var jsondiffpatch = require('./src/main-full.js'); 
                var diffArray =   diffArrayString  ; 
                var oldValue =   originalDataString  ; 
                for(var i=0; i<diffArray.length;i) { 
                var diffValue=diffArray[i]; 
                oldValue = jsondiffpatch.patch(oldValue, diffValue); 
                } 
                var data=JSON.stringify(oldValue); 

                var result = {patchedValue : data}; 
                return result 
                } 

Can you say me if jsonDiffPatch has been thought to be Thread safe ? Is it share global variables ?

It won't be surprinsing cause Javascript is mono Thread.

maxiplay avatar Nov 22 '18 14:11 maxiplay