Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime.UnhandledPromiseRejection #40

Open
ohadperry opened this issue Nov 1, 2020 · 10 comments
Open

Runtime.UnhandledPromiseRejection #40

ohadperry opened this issue Nov 1, 2020 · 10 comments

Comments

@ohadperry
Copy link

    "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

@jcardus
Copy link
Contributor

jcardus commented Dec 10, 2020

Im having the same error

@jcardus
Copy link
Contributor

jcardus commented Dec 10, 2020

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)"
]
}

@s10mcow
Copy link

s10mcow commented Mar 9, 2021

+1 same issue

@swanandvk
Copy link

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

@jcardus
Copy link
Contributor

jcardus commented Apr 13, 2021

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...

@dalumiller
Copy link

+1 same issue; any solutions?

@toolsadminatl2it
Copy link

toolsadminatl2it commented Jul 19, 2021

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.

@andreme
Copy link

andreme commented Nov 6, 2021

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);

@mekane
Copy link

mekane commented Jul 12, 2023

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.

@ghdna
Copy link
Owner

ghdna commented Jul 12, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants