提交 27619f26 编写于 作者: P Phil Hughes

Merge branch '56970-fix-mr-stuck-loading-on-error' into 'master'

Resolve "Merge request page loses state"

See merge request gitlab-org/gitlab-ce!25988
export default (fn, interval = 2000, timeout = 60000) => {
export default (fn, { interval = 2000, timeout = 60000 } = {}) => {
const startTime = Date.now();
return new Promise((resolve, reject) => {
const stop = arg => (arg instanceof Error ? reject(arg) : resolve(arg));
const next = () => {
if (Date.now() - startTime < timeout) {
if (timeout === 0 || Date.now() - startTime < timeout) {
setTimeout(fn.bind(null, next, stop), interval);
} else {
reject(new Error('SIMPLE_POLL_TIMEOUT'));
......
......@@ -165,9 +165,12 @@ export default {
});
},
initiateMergePolling() {
simplePoll((continuePolling, stopPolling) => {
this.handleMergePolling(continuePolling, stopPolling);
});
simplePoll(
(continuePolling, stopPolling) => {
this.handleMergePolling(continuePolling, stopPolling);
},
{ timeout: 0 },
);
},
handleMergePolling(continuePolling, stopPolling) {
this.service
......@@ -198,6 +201,7 @@ export default {
})
.catch(() => {
new Flash(__('Something went wrong while merging this merge request. Please try again.')); // eslint-disable-line
stopPolling();
});
},
initiateRemoveSourceBranchPolling() {
......
---
title: Disable timeout on merge request merging poll
merge_request: 25988
author:
type: fixed
......@@ -377,11 +377,29 @@ describe('ReadyToMerge', () => {
});
describe('initiateMergePolling', () => {
beforeEach(() => {
jasmine.clock().install();
});
afterEach(() => {
jasmine.clock().uninstall();
});
it('should call simplePoll', () => {
const simplePoll = spyOnDependency(ReadyToMerge, 'simplePoll');
vm.initiateMergePolling();
expect(simplePoll).toHaveBeenCalled();
expect(simplePoll).toHaveBeenCalledWith(jasmine.any(Function), { timeout: 0 });
});
it('should call handleMergePolling', () => {
spyOn(vm, 'handleMergePolling');
vm.initiateMergePolling();
jasmine.clock().tick(2000);
expect(vm.handleMergePolling).toHaveBeenCalled();
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册