// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. export function promiseTimeout(promise, ms) { const timeout = new Promise((resolve, reject) => { const id = setTimeout(() => { clearTimeout(id); reject('Timed out in ' + ms + 'ms.'); }, ms); }); return Promise.race([ promise, timeout ]); }