Skip to content

Conversation

@ericallam
Copy link
Member

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

⚠️ No Changeset found

Latest commit: b7162df

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds four new ClickHouse-related environment variables to env.server.ts: EVENTS_CLICKHOUSE_INSERT_STRATEGY, EVENTS_CLICKHOUSE_WAIT_FOR_ASYNC_INSERT, EVENTS_CLICKHOUSE_ASYNC_INSERT_MAX_DATA_SIZE, and EVENTS_CLICKHOUSE_ASYNC_INSERT_BUSY_TIMEOUT_MS, with defaults. Extends ClickhouseEventRepositoryConfig to include insertStrategy, waitForAsyncInsert, asyncInsertMaxDataSize, and asyncInsertBusyTimeoutMs. In the repository, a helper builds clickhouse_settings based on the insert strategy and options, conditionally enabling async insert parameters. Batch insert calls now pass these settings. The repository instance wires the new env values into the repository config, converting the wait flag from string to boolean.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Cohesive change across 3 files (env, config wiring, repository logic)
  • New config fields and conditional settings assembly
  • Limited algorithmic complexity; requires verification of type conversions and ClickHouse setting keys

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description is entirely missing and does not include any of the required sections from the repository template such as the issue reference, checklist, testing steps, changelog, or screenshots. Please add a pull request description following the project template by including the issue number, completed checklist items, detailed testing instructions, a brief changelog entry, and any relevant screenshots.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title succinctly describes the introduction of asynchronous insert support for ClickHouse task events via environment variables, which aligns directly with the primary change in the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ea-branch-96-1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/webapp/app/env.server.ts (1)

1126-1126: Use BoolEnv for consistency with other boolean environment variables.

The file uses BoolEnv for other boolean environment variables (e.g., lines 62, 82, 391-393). Using z.string().default("1") here requires manual conversion to boolean at the consumption site (line 47 in clickhouseEventRepositoryInstance.server.ts), which is less idiomatic.

Apply this diff to use BoolEnv:

-    EVENTS_CLICKHOUSE_WAIT_FOR_ASYNC_INSERT: z.string().default("1"),
+    EVENTS_CLICKHOUSE_WAIT_FOR_ASYNC_INSERT: BoolEnv.default(true),

Then update line 47 in clickhouseEventRepositoryInstance.server.ts:

-    waitForAsyncInsert: env.EVENTS_CLICKHOUSE_WAIT_FOR_ASYNC_INSERT === "1",
+    waitForAsyncInsert: env.EVENTS_CLICKHOUSE_WAIT_FOR_ASYNC_INSERT,
apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts (1)

145-156: Consider explicit check for "insert_async" to avoid unexpected behavior.

The current logic enables async inserts for any insertStrategy value other than "insert" (line 146). If an unexpected value or undefined is passed, async inserts would be enabled. While the environment default is "insert" so this shouldn't happen in practice, it would be safer to explicitly check for "insert_async" in the condition.

Apply this diff for more explicit logic:

 #getClickhouseInsertSettings() {
-  if (this._config.insertStrategy === "insert") {
+  if (this._config.insertStrategy !== "insert_async") {
     return {};
   } else {
     return {

This makes it clear that async inserts are only enabled when explicitly requested with "insert_async", and any other value (including undefined or unexpected values) will use the default synchronous behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63b6fc9 and b7162df.

📒 Files selected for processing (3)
  • apps/webapp/app/env.server.ts (1 hunks)
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts (3 hunks)
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • apps/webapp/app/env.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

We use zod a lot in packages/core and in the webapp

Files:

  • apps/webapp/app/env.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts
apps/webapp/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

When importing from @trigger.dev/core in the webapp, never import the root package path; always use one of the documented subpath exports from @trigger.dev/core’s package.json

Files:

  • apps/webapp/app/env.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts
{apps/webapp/app/**/*.server.{ts,tsx},apps/webapp/app/routes/**/*.ts}

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Access environment variables only via the env export from app/env.server.ts; do not reference process.env directly

Files:

  • apps/webapp/app/env.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts
apps/webapp/app/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Modules intended for test consumption under apps/webapp/app/**/*.ts must not read environment variables; accept configuration via options instead

Files:

  • apps/webapp/app/env.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts
  • apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts
🧬 Code graph analysis (2)
apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts (1)
apps/webapp/app/v3/eventRepository/eventRepository.server.ts (1)
  • events (1468-1472)
apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts (1)
apps/webapp/app/env.server.ts (1)
  • env (1207-1207)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
apps/webapp/app/v3/eventRepository/clickhouseEventRepositoryInstance.server.ts (1)

46-49: LGTM!

The new configuration options are properly wired from environment variables to the repository. The boolean conversion on line 47 is correct, though it would be simplified if the suggestion in env.server.ts is adopted.

apps/webapp/app/v3/eventRepository/clickhouseEventRepository.server.ts (1)

126-130: LGTM!

The insert call correctly passes the ClickHouse settings based on the configured insert strategy. The settings are built dynamically via the helper method and properly integrated into the insert parameters.

@ericallam ericallam merged commit a445af1 into main Oct 15, 2025
31 checks passed
@ericallam ericallam deleted the ea-branch-96-1 branch October 15, 2025 09:37
@sentry
Copy link

sentry bot commented Oct 15, 2025

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

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

Successfully merging this pull request may close these issues.

3 participants