cognito-express icon indicating copy to clipboard operation
cognito-express copied to clipboard

Runtime.UnhandledPromiseRejection

Open ohadperry opened this issue 3 years ago • 10 comments

    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "TypeError: Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established",
    "reason": {
        "errorType": "TypeError",
        "errorMessage": "Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established",
        "stack": [
            "TypeError: Unable to generate certificate due to ",
            "RequestError: Error: Client network socket disconnected before secure TLS connection was established",
            "    at /var/task/node_modules/cognito-express/lib/strategy.js:42:23",
            "    at bound (domain.js:427:14)",
            "    at runBound (domain.js:440:12)",
            "    at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)",
            "    at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)",
            "    at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)",
            "    at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)",
            "    at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)",
            "    at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)",
            "    at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)",
            "    at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)",
            "    at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)",
            "    at processImmediate (internal/timers.js:456:21)",
            "    at process.topLevelDomainCallback (domain.js:138:15)",
            "    at process.callbackTrampoline (internal/async_hooks.js:118:14)"
        ]
    },
    "promise": {
        "isFulfilled": false,
        "isRejected": true,
        "rejectionReason": {
            "errorType": "TypeError",
            "errorMessage": "Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established",
            "stack": [
                "TypeError: Unable to generate certificate due to ",
                "RequestError: Error: Client network socket disconnected before secure TLS connection was established",
                "    at /var/task/node_modules/cognito-express/lib/strategy.js:42:23",
                "    at bound (domain.js:427:14)",
                "    at runBound (domain.js:440:12)",
                "    at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)",
                "    at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)",
                "    at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)",
                "    at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)",
                "    at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)",
                "    at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)",
                "    at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)",
                "    at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)",
                "    at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)",
                "    at processImmediate (internal/timers.js:456:21)",
                "    at process.topLevelDomainCallback (domain.js:138:15)",
                "    at process.callbackTrampoline (internal/async_hooks.js:118:14)"
            ]
        }
    },
    "stack": [
        "Runtime.UnhandledPromiseRejection: TypeError: Unable to generate certificate due to ",
        "RequestError: Error: Client network socket disconnected before secure TLS connection was established",
        "    at process.<anonymous> (/var/runtime/index.js:35:15)",
        "    at process.emit (events.js:327:22)",
        "    at process.EventEmitter.emit (domain.js:483:12)",
        "    at eventToObjectGenerator.promiseCreated (/var/task/node_modules/bluebird/js/release/debuggability.js:258:33)",
        "    at activeFireEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:301:44)",
        "    at fireRejectionEvent (/var/task/node_modules/bluebird/js/release/debuggability.js:703:14)",
        "    at Promise._notifyUnhandledRejection (/var/task/node_modules/bluebird/js/release/debuggability.js:90:9)",
        "    at Timeout.unhandledRejectionCheck [as _onTimeout] (/var/task/node_modules/bluebird/js/release/debuggability.js:39:25)",
        "    at listOnTimeout (internal/timers.js:549:17)",
        "    at processTimers (internal/timers.js:492:7)"
    ]
}


enviroment:

provider: name: aws runtime: nodejs12.x lambda

ohadperry avatar Nov 01 '20 20:11 ohadperry

Im having the same error

jcardus avatar Dec 10 '20 14:12 jcardus

2020-12-10T14:31:56.852Z 2f303802-9292-42ef-88ea-6031dc709105 ERROR Invoke Error { "errorType": "TypeError", "errorMessage": "Unable to generate certificate due to \nRequestError: Error: Client network socket disconnected before secure TLS connection was established", "stack": [ "TypeError: Unable to generate certificate due to ", "RequestError: Error: Client network socket disconnected before secure TLS connection was established", " at /var/task/node_modules/cognito-express/lib/strategy.js:42:23", " at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)", " at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)", " at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)", " at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)", " at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)", " at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)", " at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)", " at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)", " at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)", " at processImmediate (internal/timers.js:461:21)" ] }

jcardus avatar Dec 10 '20 14:12 jcardus

+1 same issue

s10mcow avatar Mar 09 '21 15:03 s10mcow

+1 having the same , whats the root cause of this any intel ?

swanandvk avatar Apr 08 '21 07:04 swanandvk

I had this again today. I gave more memory to the lambda function, it was 128, it's now 1024. It's a shot in the dark...

jcardus avatar Apr 13 '21 13:04 jcardus

+1 same issue; any solutions?

dalumiller avatar Apr 23 '21 20:04 dalumiller

We are facing this issue very frequently. Is there any solution to this? Is it because of the cold start in the lambda environment? We have noticed in our error monitoring tool that all the transactions with this issue had the cold start.

toolsadminatl2it avatar Jul 19 '21 13:07 toolsadminatl2it

This is a wrapper that retries downloading the certificates if it fails for some reason:

let cognitoExpress;
async function cogValidateToken(token, retryCounter = 0) {

	if (!cognitoExpress) {
		cognitoExpress = new CognitoExpress({
			region: 'SET',
			cognitoUserPoolId: 'SET',
			tokenUse: 'access',
		});
	}

	try {
		return await cognitoExpress.validate(token);
	} catch (e) {
		if ((retryCounter < 25) && String(e.message).startsWith('Unable to generate certificate due to')) {
			console.error(e);
			cognitoExpress = null;
			return cogValidateToken(token, retryCounter + 1);
		}

		throw e;
	}
}

Call with

const jwt = await cogValidateToken(token);

andreme avatar Nov 06 '21 15:11 andreme

I'm running into this in my CI/CD where the VM doesn't have network access. Line 54 of strategy.js is throwing with no catch and I can't find a way to quiet it down.

mekane avatar Jul 12 '23 14:07 mekane

Ok lemme take a look

On Wed, Jul 12, 2023 at 10:52 AM Marty Kane @.' via 33Mail @.> wrote:

This email was sent to the alias @.' by ' @.', and 33Mail forwarded it to you. To block all further emails to this alias click here http://www.33mail.com/alias/unsub/41bdfade131b958a27a3e30e285264d5

I'm running into this in my CI/CD where the VM doesn't have network access. Line 54 of strategy.js is throwing with no catch and I can't find a way to quiet it down.

— Reply to this email directly, view it on GitHub https://github.com/ghdna/cognito-express/issues/40#issuecomment-1632686122, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGRKZRDHLD53XHA4NHZPWDXP224FANCNFSM4TGW7ZFQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ghdna avatar Jul 12 '23 22:07 ghdna