-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat: handled unknown dialect for cloud #1450
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,7 +238,12 @@ export class DBTCloudProjectIntegration | |
} | ||
if (!this.adapterType) { | ||
// We only fetch the adapter type once, as it may impact compilation preview otherwise | ||
this.findAdapterType(); | ||
const startTime = Date.now(); | ||
await this.findAdapterType(); | ||
const elapsedTime = Date.now() - startTime; | ||
this.telemetry.sendTelemetryEvent("cloudFindAdapterTypeElapsedTime", { | ||
elapsedTime: elapsedTime.toString(), | ||
}); | ||
} | ||
if (!this.version) { | ||
await this.findVersion(); | ||
|
@@ -1023,6 +1028,21 @@ export class DBTCloudProjectIntegration | |
} | ||
} | ||
|
||
private firstRun = false; | ||
private async retryOnce() { | ||
if (this.firstRun) { | ||
return; | ||
} | ||
this.firstRun = true; | ||
const startTime = Date.now(); | ||
await this.findAdapterType(); | ||
const elapsedTime = Date.now() - startTime; | ||
this.telemetry.sendTelemetryEvent("cloudFindAdapterTypeElapsedTime", { | ||
elapsedTime: elapsedTime.toString(), | ||
retry: "true", | ||
}); | ||
} | ||
|
||
private async findAdapterType() { | ||
const adapterTypeCommand = this.dbtCloudCommand( | ||
new DBTCommand("Getting adapter type...", [ | ||
|
@@ -1063,6 +1083,11 @@ export class DBTCloudProjectIntegration | |
error, | ||
); | ||
} | ||
if (!this.adapterType) { | ||
setTimeout(() => { | ||
this.retryOnce(); | ||
}, 5000); | ||
} | ||
Comment on lines
+1086
to
+1090
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider enhancing the retry mechanism. The addition of a retry mechanism for adapter type detection is a good improvement for handling transient issues. However, there are a few points to consider:
Here's a suggestion to address these points: private retryCount = 0;
private readonly MAX_RETRIES = 3;
private isRetrying = false;
private async findAdapterType() {
// ... existing code ...
if (!this.adapterType && this.retryCount < this.MAX_RETRIES && !this.isRetrying) {
this.retryCount++;
this.isRetrying = true;
setTimeout(async () => {
await this.retryOnce();
this.isRetrying = false;
}, 5000);
}
} This approach limits the number of retries, prevents concurrent retries, and keeps the retry logic within the |
||
} | ||
|
||
private async findVersion() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a return type to the
retryOnce
function signature for better clarity and refactoring ease.