return Server.create({ port: 3000 }).then(function () { baseServer.listeners('request')[0](socket, {}, function () { assertLogged('debug', '[test:3000] host:port => "full request"'); }); // The delay is not needed in node v0.10; evidently it came on a later process tick in subsequent versions return Q.delay(1); });
createSocketToApp(retryAttempt = false) { let deferred = Q.defer(); this.socketToApp = this.webSocketConstructor(this.debuggerProxyUrl()); this.socketToApp.on("open", () => { this.onSocketOpened(); }); this.socketToApp.on("close", () => { this.executionLimiter.execute("onSocketClose.msg", /*limitInSeconds*/ 10, () => { /* * It is not the best idea to compare with the message, but this is the only thing React Native gives that is unique when * it closes the socket because it already has a connection to a debugger. * https://github.com/facebook/react-native/blob/588f01e9982775f0699c7bfd56623d4ed3949810/local-cli/server/util/webSocketProxy.js#L38 */ let msgKey = "_closeMessage"; if (this.socketToApp[msgKey] === "Another debugger is already connected") { deferred.reject(new RangeError("Another debugger is already connected to packager. Please close it before trying to debug with VSCode.")); } vscode_chrome_debug_core_1.logger.log("Disconnected from the Proxy (Packager) to the React Native application. Retrying reconnection soon..."); }); setTimeout(() => { this.start(true /* retryAttempt */); }, 100); }); this.socketToApp.on("message", (message) => this.onMessage(message)); this.socketToApp.on("error", (error) => { if (retryAttempt) { printDebuggingError("Reconnection to the proxy (Packager) failed. Please check the output window for Packager errors, if any. If failure persists, please restart the React Native debugger.", error); } deferred.reject(error); }); // In an attempt to catch failures in starting the packager on first attempt, // wait for 300 ms before resolving the promise Q.delay(300).done(() => deferred.resolve(void 0)); return deferred.promise; }
return spinFn().catch(function (err) { if (Date.now() < endAt) { return Q.delay(intMs).then(spin); } else { throw new Error("spinWait condition unfulfilled. Promise rejected with error:", err); } });
function downloadNext() { if (!queue.length) { return; } downloadedCounter++; if (MAX_DOWNLOADS && downloadedCounter > MAX_DOWNLOADS) { return; } var query = queue.shift(); Q.delay(CRAWL_DELAY * 1000) .then(function () { console.log("Downloading", {query: query, queueLength: queue.length}); return Q.nfcall(request, getRequestOptions(query)); }) .spread(function (res) { console.log("Saving", {query: query, bodyLength: res.body.length}); return saveResults(query, res); }) .then(function (res) { return queueNext(query, res); }) .catch(function (err) { console.error("Retrying", {query: query, error: err}); queue.push(query); // retry }) .then(function () { downloadNext(); }) .done(); }
before(function () { return Q.delay(500).then(function() { return createTransactionPendingApproval(); }) .then(function (result) { pendingApproval = result; }); });
}).then(function(result) { var res=convert(result.buf); //console.log(res); // console.log("from 0x"+res.src.toString(16)+" ID:"+res.ID.toString(16)+" hops: "+res.hops); console.log(res.type+" "+res.hops+" "+res.src+" "+res.ID+" "+res.sensor.temp+" "+res.sensor.humidity+" "+res.sensor.pressure); deferredTop.resolve(Q.delay(1000)); }).
process.openStdin().on('keypress', function(chunk, key) { if(key && key.name === 'c' && key.ctrl) { Q.delay(2000).then(function () { ƒ(); d.resolve(); }); } });
.then(function (execution) { if (execution.error) throw new Error(execution.error); else if ("result" in execution) return { result: execution.result, done: true }; return Q.delay(500).then(tryGetResult.bind(null, executionId, timeLimit)); });
TouchstartButton.prototype.onTouchstart = function (evt) { if (!this.active && (!this.monotouchable || !this.isLocked())) { var btn = this; if(btn.monotouchable) btn.lock(); btn.setActive(true); Q.delay(evt, btn.delay).then(btn.f).finally(_done(btn)).done(); } };
onAccounts = function(accounts) { if (doneRefreshing(accounts)) return self; self.emit('refreshing', accounts); return Q.delay(10000).then(function() { return self.getRefreshingAccounts().then(onAccounts); }); };
return Q.nfcall(soyCompiler.compileTemplates.bind(soyCompiler), __dirname + '/assets').then(function () { test.equal('The default template', soyCompiler.render('template3.main', {})) test.equal('Hello world', soyCompiler.render('template3.main', {type: 'hello'})) test.equal('The default template', soyCompiler.render('template3.main', {type: 'goodbye'})) time += 1000 return Q.delay(1) }).then(function () {
testUtils.logout(driver, function() { q.delay(1000).then(function(){ return driver.findElement(webdriver.By.css('.main-area .user-area.js-has-user-menu .sign-in')).isDisplayed(); }).then(function(t) { assert.equal(t, true, "logout failed"); done(); }); });
var h1 = function() { expect(h2_fired).toBe(false); // Delay 100 ms here to check that h2 is not executed until after // the promise returned by h1 is resolved. var q = Q.delay(100).then(function() { h1_fired = true; }); return q; };
return function (evt) { logEl.innerHTML = 'start ' + label; return Q.delay(1000).then(function () { logEl.innerHTML = 'end ' + label; return Q.delay(1000).then(function () { logEl.innerHTML = ''; }); }); }
return getTransaction(txid).then(function (tx) { if (tx.blockNumber) { return tx; } else { return Q.delay(1000).then(function () { return getMinedTransaction(txid); }); } });
run: sinon.spy(function () { const call = { start: Date.now() }; this.calls.push(call); console.log('run', Date.now()); return Q.delay(300).then(() => { call.end = Date.now(); return 1; }); }),
}, function() { if (retries === 0) { throw new Error("Can't upload to " + JSON.stringify(serverURI)); } return q.delay(timeout) .then(function() { return fileUploadRetry(fileURI, serverURI, fileUploadOptions, timeout, retries - 1); }); });
.then(function(result) { result.should.have.property('tx'); result.should.have.property('hash'); result.should.have.property('fee'); return Q.delay(3500) .then(function() { return testWallet.get(); }) })
request.on('error', function (error) { if (attemptCount >= 4) { log.error(error, 'Send CFN result failed (giving up)'); context.done(); } else { log.warn(error, 'Send CFN result failed (will retry)'); q.delay(250).then(sendRequest); } });
return inbox.search(criteria, { markSeen: true }).then(function(messages) { messages = messages.filter(function(message) { return message.recipients[0] === username && message.body.match(regexp); // Imap search would find all the '+' suffixed messages too }); return messages.length ? messages.pop() : Q.delay(1000).then(function() { return search(); }); });
}, function() { // Not started, keep polling unless the timeout has fired already if (startOrTimeout.isPending()) { logDebug("Runtime not up yet, scheduling another check..."); Q.delay(START_POLL).then(check); } else { logDebug("Start timed out after %s seconds.", toSecs(Date.now() - startTime)); } });
function go () { Q.delay(100) .then('promiseOne') .delay(1000) .then('promiseTwo') .then(function () { cycle(); }); }
it("should reject if the last call rejects, even if the first fulfills", function () { var try1 = wrapped(1); var try2 = wrapped(3); return Q.delay(150).then(function () { try1.inspect().should.deep.equal({ state: "pending" }); try2.inspect().should.deep.equal({ state: "rejected", reason: "c" }); }); });
var next = d.promise.finally(function() { print_args(arguments); console.log("d is done. " + explain("next", next)); q.delay(100).then(function() { console.log("timeout. " + explain("next", next)); dd.reject("return!"); }); return dd.promise; });
}, function (error) { if (times == 0) throw new Error("Promise retry failed" + promise.toString()); return Q.delay(timeout) .then(function () { debug('retrying promise, times: ', times); return UTIL.retryPromiseForTor(options, timeout, times - 1); }); });
promiseWhile(function () { return index < locations.length; }, function () { sendRequest(locations[index].address) .then(function(res){ user.locations[index].longitude = res.longitude; user.locations[index].latitude = res.latitude; index++; }); return Q.delay(300); // arbitrary async }).then(function () {
it("should fulfill the last-created promise, and leave earlier ones pending", function () { var try1 = wrapped(1); var try2 = wrapped(2); return Q.delay(150).then(function () { try1.inspect().should.deep.equal({ state: "pending" }); try2.inspect().should.deep.equal({ state: "fulfilled", value: "b" }); }); });
.then(function (new_started) { if (new_started.length > num_running) { return new_started; } else { return Q.delay(1000).then(function () { return self.wait_for_emulator(num_running); }); } });
return promiseFunc().catch(function (err) { if (iteration < maxTries) { return Q.delay(delay).then(function () { return retryAsync(promiseFunc, maxTries, delay, iteration + 1); }); } return Q.reject(err); });
function(streamHash) { count++; return Q.delay(count*__.SUBSCRIPTION_DELAY).then( function(){ return self.subscribe(streamHash); } ); }).concat(unsubscribedPromises);