8000 Intermittent file not done piping · Issue #53 · davglass/cpr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Intermittent file not done piping #53
Open
@kellyselden

Description

@kellyselden

Given a file named "changed.txt" with the contents:

changed-v1

And with the following code added to the copyFile function:

            fromFile.on('error', onError);
            toFile.on('error', onError);
            fromFile.once('end', function() {
                cb(err);
                if (to === 'changed.txt') {
                  console.error(to);
                  console.error(fs.readFileSync(from, 'utf8'));
                  console.error(fs.readFileSync(to, 'utf8'));
                }
            });
            fromFile.pipe(toFile);

About 50% of the time I get in the console:

changed.txt
changed-v1

changed-v1

And the other 50% I get:

changed.txt
changed-v1


It seems like there may be a race condition in the piping and "end" event. I should also note that there are other files in the operation, and this is the only one affected. For instance using fixturify:

{ 'changed.txt': '',
  'missing-changed.txt': 'changed-v1\n',
  'missing-unchanged.txt': 'unchanged\n',
  'removed-changed.txt': 'changed-v1\n',
  'removed-unchanged.txt': 'unchanged\n',
  'unchanged.txt': 'unchanged\n' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0