Skip to content

Commit

Permalink
fix(#198): use "finish" event instead of "end" to avoid race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kay-schecker committed Dec 23, 2020
1 parent e1fab63 commit a5f6dce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,15 @@ describe('VersionManagerService', () => {

const data = {
pipe: jest.fn(),
};

const file = {
on: jest.fn().mockImplementation((listener, res) => {
if (listener === 'end') {
if (listener === 'finish') {
return res();
}
})
};

const file = Symbol();
}

beforeEach(async () => {
data.pipe.mockReset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class VersionManagerService {
fs.ensureDirSync(this.storage);
const file = fs.createWriteStream(filePath);
res.data.pipe(file);
res.data.on('end', resolve);
file.on('finish', resolve);
})
)).toPromise();

Expand Down

0 comments on commit a5f6dce

Please sign in to comment.