Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/webapp/app/services/clickhouseInstance.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ function initializeClickhouseClient() {
return;
}

console.log("🗃️ Clickhouse service enabled");
const url = new URL(env.CLICKHOUSE_URL);

Comment on lines +13 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for URL parsing.

The URL constructor will throw an error if env.CLICKHOUSE_URL is malformed. Consider adding error handling to provide a more informative error message.

- const url = new URL(env.CLICKHOUSE_URL);
+ let url;
+ try {
+   url = new URL(env.CLICKHOUSE_URL);
+ } catch (error) {
+   console.error(`🗃️  Invalid CLICKHOUSE_URL: ${env.CLICKHOUSE_URL}`, error);
+   return;
+ }
🤖 Prompt for AI Agents
In apps/webapp/app/services/clickhouseInstance.server.ts around lines 13 to 14,
the URL constructor is used directly on env.CLICKHOUSE_URL without error
handling, which can throw if the URL is malformed. Wrap the URL construction in
a try-catch block to catch any errors, and throw a new error with a clear,
informative message indicating that the CLICKHOUSE_URL environment variable is
invalid or malformed.

// Remove secure param
url.searchParams.delete("secure");

console.log(`🗃️ Clickhouse service enabled to host ${url.host}`);

const clickhouse = new ClickHouse({
url: env.CLICKHOUSE_URL,
url: url.toString(),
name: "clickhouse-instance",
keepAlive: {
enabled: env.CLICKHOUSE_KEEP_ALIVE_ENABLED === "1",
Expand Down
Loading