Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear git-promise timeout when git command was successful #1357

Merged
merged 3 commits into from
May 13, 2020

Conversation

campersau
Copy link
Collaborator

@campersau campersau commented May 11, 2020

While trying to migrate from grunt to script files, I noticed that the mocha unittest weren't existing right away. I tracked the problem down with wtfnode to our git-promise timeout (introduced in #1192) which wasn't cancelled if the git call was successful and didn't timed out.

@ylecuyer
Copy link
Contributor

Nice finding. Maybe we can add a test for it? Just checking that clearTimeout is called wdyt?

@campersau
Copy link
Collaborator Author

I could add a test like this but hacking global variables for that feels a bit dirty and may have sideeffets when other code also uses it.

const expect = require('expect.js');
const git = require('../source/git-promise');

describe('git-promise', () => {
    it('should clear git timeout when successful', async () => {
        let clearTimeoutCallCount = 0;
        const originalClearTimeout = clearTimeout;
        clearTimeout = (arg) => {
            clearTimeoutCallCount++;
            originalClearTimeout(arg);
        }

        try {
            await git(['version']);

            expect(clearTimeoutCallCount).to.equal(1);
        } finally {
            clearTimeout = originalClearTimeout;
        }
    });
});

source/git-promise.js Outdated Show resolved Hide resolved
@campersau campersau merged commit 88f4a86 into FredrikNoren:master May 13, 2020
@campersau campersau deleted the cleartimeout branch May 13, 2020 20:28
@campersau campersau mentioned this pull request Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants