From 795c436cb1c6dbe457fc472ab17276cf3b99e923 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Thu, 8 Jun 2017 09:35:03 -0700 Subject: [PATCH] FBGlobalTransformCache: retry 3 times, wait between retries Summary: That should improve the hit rate a little bit, notably for the cache-filling script. On OSS side, this changeset only adds the sleep() function as `FBGlobalTransformCache` is not exposed. Reviewed By: cpojer Differential Revision: D5201196 fbshipit-source-id: c2d8e1a1b03edd9e7747b3202c574b0783f4117d --- packages/metro-bundler/src/lib/sleep.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/metro-bundler/src/lib/sleep.js diff --git a/packages/metro-bundler/src/lib/sleep.js b/packages/metro-bundler/src/lib/sleep.js new file mode 100644 index 00000000..fe507e45 --- /dev/null +++ b/packages/metro-bundler/src/lib/sleep.js @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + */ + +'use strict'; + +function sleep(duration: number): Promise { + return new Promise(resolve => { + setTimeout(resolve, duration); + }); +} + +module.exports = sleep;