AvianFlu / ncp

Asynchronous recursive file copying with Node.js.
MIT License
681 stars 103 forks source link

Wrong Callback Invoked Under High Concurrency #25

Closed ckneumann closed 10 years ago

ckneumann commented 11 years ago

(The following was discovered during concurrency testing using loader.io.)

Example:

ncp(path, newpath, function(error) {
  if(error) {
    ...
  } else {
    foo(newpath,...);
  }
});

If the above code is run under high concurrency, where multiple calls to ncp are executing in parallel, a given callback function may be invoked multiple times. For example, concurrent calls to:

Copy A -> X Copy A -> Y Copy A -> Z

results in three calls to the callback that invokes foo(Z).

AvianFlu commented 10 years ago

Should be fixed by #25