Skip to content

Commit

Permalink
Handle errors thrown by cls.exit failing an assert. (#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonWeber committed Feb 26, 2024
1 parent 055355c commit 1b53f5a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 20 deletions.
17 changes: 14 additions & 3 deletions AutoCollection/CorrelationContextManager.ts
Expand Up @@ -178,8 +178,13 @@ export class CorrelationContextManager {
this.cls = require("continuation-local-storage");
}
}

CorrelationContextManager.session = this.cls.createNamespace("AI-CLS-Session");
try {
CorrelationContextManager.session = this.cls.createNamespace("AI-CLS-Session");
} catch (error) {
Logging.warn("Failed to create AI-CLS-Session namespace. Correlation of requests may be lost", Util.dumpObj(error));
this.enabled = false;
return;
}

DiagChannel.registerContextPreservation((cb) => {
try {
Expand Down Expand Up @@ -295,7 +300,13 @@ export class CorrelationContextManager {
public static reset() {
if (CorrelationContextManager.hasEverEnabled) {
CorrelationContextManager.session = null;
CorrelationContextManager.session = this.cls.createNamespace("AI-CLS-Session");
try {
CorrelationContextManager.session = this.cls.createNamespace("AI-CLS-Session");
} catch (error) {
Logging.warn("Failed to create AI-CLS-Session namespace. Correlation of requests may be lost", Util.dumpObj(error));
this.enabled = false;
return;
}
}
}

Expand Down
46 changes: 29 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1b53f5a

Please sign in to comment.