From 6318db60751c6683a19249a8d97877f8fc31884c Mon Sep 17 00:00:00 2001 From: Roman Shtylman Date: Sun, 10 Dec 2017 10:14:59 -0800 Subject: [PATCH] remove babel async to generator transform --- .babelrc | 1 - package.json | 1 - proxy.js | 22 +++++++++++++++++----- yarn.lock | 41 +---------------------------------------- 4 files changed, 18 insertions(+), 47 deletions(-) diff --git a/.babelrc b/.babelrc index ffd53e0..2ce79c5 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,5 @@ { "plugins": [ "transform-es2015-modules-commonjs", - "transform-async-to-generator", ] } diff --git a/package.json b/package.json index e838166..bc7868d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "url": "git://github.com/localtunnel/server.git" }, "dependencies": { - "babel-plugin-transform-async-to-generator": "6.8.0", "babel-plugin-transform-es2015-modules-commonjs": "6.10.3", "babel-polyfill": "6.9.1", "babel-register": "6.9.0", diff --git a/proxy.js b/proxy.js index 75d5e3e..26143a9 100644 --- a/proxy.js +++ b/proxy.js @@ -166,10 +166,7 @@ Proxy.prototype.next_socket = function(handler) { self.debug('processing request'); handler(sock) - .catch((err) => { - log.error(err); - }) - .finally(() => { + .then(() => { if (!sock.destroyed) { self.debug('retuning socket'); self.sockets.push(sock); @@ -181,7 +178,22 @@ Proxy.prototype.next_socket = function(handler) { } self._process_waiting(); - }); + }) + .catch((err) => { + log.error(err); + + if (!sock.destroyed) { + self.debug('retuning socket'); + self.sockets.push(sock); + } + + // no sockets left to process waiting requests + if (self.sockets.length === 0) { + return; + } + + self._process_waiting(); + }) }; Proxy.prototype._done = function() { diff --git a/yarn.lock b/yarn.lock index 6d83084..eea2e61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -100,33 +100,6 @@ babel-generator@^6.26.0: source-map "^0.5.6" trim-right "^1.0.1" -babel-helper-function-name@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" - dependencies: - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-get-function-arity@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-remap-async-to-generator@^6.8.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babel-helpers@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" @@ -140,18 +113,6 @@ babel-messages@^6.23.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-syntax-async-functions@^6.8.0: - version "6.13.0" - resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" - -babel-plugin-transform-async-to-generator@6.8.0: - version "6.8.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.8.0.tgz#fbb154f2912e00b9f0972131d7e03ebbe45684c2" - dependencies: - babel-helper-remap-async-to-generator "^6.8.0" - babel-plugin-syntax-async-functions "^6.8.0" - babel-runtime "^6.0.0" - babel-plugin-transform-es2015-modules-commonjs@6.10.3: version "6.10.3" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.10.3.tgz#e4993a455518ca1a3c580bfda35c074e40659c5f" @@ -218,7 +179,7 @@ babel-template@^6.24.1, babel-template@^6.26.0, babel-template@^6.8.0: babylon "^6.18.0" lodash "^4.17.4" -babel-traverse@^6.24.1, babel-traverse@^6.26.0: +babel-traverse@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" dependencies: