@5minds/processcube_engine_client
Advanced tools
Comparing version 5.1.6-hotfix-109794-m5wuvr8z to 5.1.6-hotfix-c47afe-m5zehffo
@@ -122,2 +122,9 @@ "use strict"; | ||
} | ||
if (error.message?.match(/expired/i) && this.identityAccessor.canIdentityBeRefreshed()) { | ||
this.logger.info('Identity has expired. Refreshing identity to get a new auth token...'); | ||
this.identityAccessor | ||
.forceImmediateIdentityRefresh() | ||
.then(() => this.logger.info('Identity refresh completed. Fetch and Lock will continue.')) | ||
.catch((refreshError) => this.logger.error('Identity refresh failed', { err: refreshError })); | ||
} | ||
} | ||
@@ -124,0 +131,0 @@ } |
@@ -122,2 +122,7 @@ "use strict"; | ||
logger.error('Failed to fetch and lock External Tasks.', { err: error }); | ||
if (error.message?.match(/expired/i) && this.identityAccessor.canIdentityBeRefreshed()) { | ||
logger.info('Identity has expired. Refreshing identity to get a new auth token...'); | ||
await this.identityAccessor.forceImmediateIdentityRefresh(); | ||
logger.info('Identity refresh completed. Fetch and Lock will continue.'); | ||
} | ||
errorCount++; | ||
@@ -124,0 +129,0 @@ const timeoutOffset = (Math.floor(Math.random() * 10) + 1) * 30; |
@@ -86,3 +86,2 @@ "use strict"; | ||
identityAvailableReject; | ||
identityCanBeRefreshed = true; | ||
refreshFailedCritically = false; | ||
@@ -126,3 +125,3 @@ refreshTimeout; | ||
canIdentityBeRefreshed() { | ||
return this.identityCanBeRefreshed; | ||
return this.isDynamicRefreshObject && this.expirationTimeInMs > 0 && !this.refreshFailedCritically && !this.disposed; | ||
} | ||
@@ -134,3 +133,3 @@ async getIdentity() { | ||
async forceImmediateIdentityRefresh() { | ||
if (!this.identityCanBeRefreshed) { | ||
if (!this.isDynamicRefreshObject) { | ||
return; | ||
@@ -180,4 +179,3 @@ } | ||
clearTimeout(this.refreshTimeout); | ||
this.identityCanBeRefreshed = this.isDynamicRefreshObject && this.expirationTimeInMs > 0 && !this.refreshFailedCritically && !this.disposed; | ||
if (this.identityCanBeRefreshed) { | ||
if (this.canIdentityBeRefreshed()) { | ||
const timeUntilNextRefresh = Math.max((this.expirationTimeInMs ?? 0) - Date.now() - this.getBaseMinRefreshTimeInMs(), this.getBaseMinRefreshTimeInMs()); | ||
@@ -191,3 +189,3 @@ const timeUntilNextRefresh32Bit = Math.min(timeUntilNextRefresh, 2147483647); | ||
else if (this.refreshFailedCritically) { | ||
this.logger.error('Identity refresh failed critically and wont be refreshed anymore.'); | ||
this.logger.error(`Identity refresh failed critically and won't be refreshed anymore.`); | ||
this.identityAvailableReject(new Error('Identity refresh failed critically and wont be refreshed anymore.')); | ||
@@ -194,0 +192,0 @@ } |
@@ -20,7 +20,6 @@ import { Identity, Logger } from '@5minds/processcube_engine_sdk'; | ||
private identityAvailableReject; | ||
private identityCanBeRefreshed; | ||
private refreshFailedCritically; | ||
private refreshTimeout; | ||
private disposed; | ||
private isDynamicRefreshObject; | ||
protected refreshFailedCritically: boolean; | ||
protected refreshTimeout: NodeJS.Timeout; | ||
protected disposed: boolean; | ||
protected isDynamicRefreshObject: boolean; | ||
protected logger: Logger; | ||
@@ -27,0 +26,0 @@ private newIdentityCallbacks; |
@@ -7,3 +7,3 @@ { | ||
"name": "@5minds/processcube_engine_client", | ||
"version": "5.1.6-hotfix-109794-m5wuvr8z", | ||
"version": "5.1.6-hotfix-c47afe-m5zehffo", | ||
"description": "Contains a typescript based client for accessing the Engine.", | ||
@@ -10,0 +10,0 @@ "main": "dist/commonjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
356942
5093