title: aws lambda error due to Client network socket disconnected before secure TLS connection was established
body: <p>The error appear to originated from  <code>cognito-express</code> npm but The code is not using cognito at that point at all.
  What could be root cause?</p>
  <pre><code>2020-11-01T10:34:16.482Z    7fc3f543-6bc1-43f5-a2df-afcee90c8ff5    ERROR   (node:8) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
  
  </code></pre>
  <pre><code>2020-11-01T10:34:16.496Z    7fc3f543-6bc1-43f5-a2df-afcee90c8ff5    ERROR   Unhandled Promise Rejection     
  {
      &quot;errorType&quot;: &quot;Runtime.UnhandledPromiseRejection&quot;,
      &quot;errorMessage&quot;: &quot;TypeError: Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,
      &quot;reason&quot;: {
          &quot;errorType&quot;: &quot;TypeError&quot;,
          &quot;errorMessage&quot;: &quot;Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,
          &quot;stack&quot;: [
              &quot;TypeError: Unable to generate certificate due to &quot;,
              &quot;RequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,
              &quot;    at /var/task/node_modules/cognito-express/lib/strategy.js:42:23&quot;,
              &quot;    at bound (domain.js:427:14)&quot;,
              &quot;    at runBound (domain.js:440:12)&quot;,
              &quot;    at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)&quot;,
              &quot;    at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)&quot;,
              &quot;    at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)&quot;,
              &quot;    at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)&quot;,
              &quot;    at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)&quot;,
              &quot;    at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)&quot;,
              &quot;    at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)&quot;,
              &quot;    at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)&quot;,
              &quot;    at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)&quot;,
              &quot;    at processImmediate (internal/timers.js:456:21)&quot;,
              &quot;    at process.topLevelDomainCallback (domain.js:138:15)&quot;,
              &quot;    at process.callbackTrampoline (internal/async_hooks.js:118:14)&quot;
          ]
      },
      &quot;promise&quot;: {
          &quot;isFulfilled&quot;: false,
          &quot;isRejected&quot;: true,
          &quot;rejectionReason&quot;: {
              &quot;errorType&quot;: &quot;TypeError&quot;,
              &quot;errorMessage&quot;: &quot;Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,
              &quot;stack&quot;: [
                  &quot;TypeError: Unable to generate certificate due to &quot;,
                  &quot;RequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,
                  &quot;    at /var/task/node_modules/cognito-express/lib/strategy.js:42:23&quot;,
                  &quot;    at bound (domain.js:427:14)&quot;,
                  &quot;    at runBound (domain.js:440:12)&quot;,
                  &quot;    at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)&quot;,
                  &quot;    at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)&quot;,
                  &quot;    at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)&quot;,
                  &quot;    at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)&quot;,
                  &quot;    at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)&quot;,
                  &quot;    at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)&quot;,
                  &quot;    at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)&quot;,
                  &quot;    at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)&quot;,
                  &quot;    at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)&quot;,
                  &quot;    at processImmediate (internal/timers.js:456:21)&quot;,
                  &quot;    at process.topLevelDomainCallback (domain.js:138:15)&quot;,
                  &quot;    at process.callbackTrampoline (internal/async_hooks.js:118:14)&quot;
              ]
          }
      },
      &quot;stack&quot;: [
          &quot;Runtime.UnhandledPromiseRejection: TypeError: Unable to generate certificate due to &quot;,
          &quot;RequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,
          &quot;    at process.&lt;anonymous&gt; (/var/runtime/index.js:35:15)&quot;,
          &quot;    at process.emit (events.js:327:22)&quot;,
          &quot;    at process.EventEmitter.emit (domain.js:483:12)&quot;,
          &quot;    at eventToObjectGenerator.promiseCreated (/var/task/node_modules/bluebird/js/release/debuggability.js:258:33)&quot;,
          &quot;    at activeFireEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:301:44)&quot;,
          &quot;    at fireRejectionEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:703:14)&quot;,
          &quot;    at Promise._notifyUnhandledRejection (/var/task/node_modules/bluebird/js/release/debuggability.js:90:9)&quot;,
          &quot;    at Timeout.unhandledRejectionCheck [as _onTimeout] (/var/task/node_modules/bluebird/js/release/debuggability.js:39:25)&quot;,
          &quot;    at listOnTimeout (internal/timers.js:549:17)&quot;,
          &quot;    at processTimers (internal/timers.js:492:7)&quot;
      ]
  }
  
  2020-11-01T10:34:16.496Z 7fc3f543-6bc1-43f5-a2df-afcee90c8ff5 ERROR Unhandled Promise Rejection {&quot;errorType&quot;:&quot;Runtime.UnhandledPromiseRejection&quot;,&quot;errorMessage&quot;:&quot;TypeError: Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,&quot;reason&quot;:{&quot;errorType&quot;:&quot;TypeError&quot;,&quot;errorMessage&quot;:&quot;Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,&quot;stack&quot;:[&quot;TypeError: Unable to generate certificate due to &quot;,&quot;RequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,&quot; at /var/task/node_modules/cognito-express/lib/strategy.js:42:23&quot;,&quot; at bound (domain.js:427:14)&quot;,&quot; at runBound (domain.js:440:12)&quot;,&quot; at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)&quot;,&quot; at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)&quot;,&quot; at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)&quot;,&quot; at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)&quot;,&quot; at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)&quot;,&quot; at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)&quot;,&quot; at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)&quot;,&quot; at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)&quot;,&quot; at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)&quot;,&quot; at processImmediate (internal/timers.js:456:21)&quot;,&quot; at process.topLevelDomainCallback (domain.js:138:15)&quot;,&quot; at process.callbackTrampoline (internal/async_hooks.js:118:14)&quot;]},&quot;promise&quot;:{&quot;isFulfilled&quot;:false,&quot;isRejected&quot;:true,&quot;rejectionReason&quot;:{&quot;errorType&quot;:&quot;TypeError&quot;,&quot;errorMessage&quot;:&quot;Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,&quot;stack&quot;:[&quot;TypeError: Unable to generate certificate due to &quot;,&quot;RequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,&quot; at /var/task/node_modules/cognito-express/lib/strategy.js:42:23&quot;,&quot; at bound (domain.js:427:14)&quot;,&quot; at runBound (domain.js:440:12)&quot;,&quot; at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)&quot;,&quot; at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)&quot;,&quot; at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)&quot;,&quot; at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)&quot;,&quot; at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)&quot;,&quot; at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)&quot;,&quot; at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)&quot;,&quot; at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)&quot;,&quot; at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)&quot;,&quot; at processImmediate (internal/timers.js:456:21)&quot;,&quot; at process.topLevelDomainCallback (domain.js:138:15)&quot;,&quot; at process.callbackTrampoline (internal/async_hooks.js:118:14)&quot;]}},&quot;stack&quot;:[&quot;Runtime.UnhandledPromiseRejection: TypeError: Unable to generate certificate due to &quot;,&quot;RequestError: Error: Client network socket disconnected before secure TLS connection was established&quot;,&quot; at process.&lt;anonymous&gt; (/var/runtime/index.js:35:15)&quot;,&quot; at process.emit (events.js:327:22)&quot;,&quot; at process.EventEmitter.emit (domain.js:483:12)&quot;,&quot; at eventToObjectGenerator.promiseCreated (/var/task/node_modules/bluebird/js/release/debuggability.js:258:33)&quot;,&quot; at activeFireEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:301:44)&quot;,&quot; at fireRejectionEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:703:14)&quot;,&quot; at Promise._notifyUnhandledRejection (/var/task/node_modules/bluebird/js/release/debuggability.js:90:9)&quot;,&quot; at Timeout.unhandledRejectionCheck [as _onTimeout] (/var/task/node_modules/bluebird/js/release/debuggability.js:39:25)&quot;,&quot; at listOnTimeout (internal/timers.js:549:17)&quot;,&quot; at processTimers (internal/timers.js:492:7)&quot;]}
  
  
  </code></pre>
  <p>This has happened in multiple endpoints</p>