Skip to content

Conversation

rharkor
Copy link
Contributor

@rharkor rharkor commented Sep 10, 2025

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Issue

When you delete TaskRun manually from the database you can get this error on the webapp due to some data corruption. You will not be able to start the webapp again until dropping the replication slot.

2025-09-02T07:04:37.301Z {"error":{"name":"TypeError","message":"Cannot read properties of null (reading 'id')","stack":"TypeError: Cannot read properties of null (reading 'id')\n    at Object.mergeBatch (/triggerdotdev/apps/webapp/build/index.js:111786:47)\n    at ConcurrentFlushScheduler.addToBatch (/triggerdotdev/apps/webapp/build/index.js:112206:62)\n    at #handleTransaction (/triggerdotdev/apps/webapp/build/index.js:111913:36)\n    at #handleData (/triggerdotdev/apps/webapp/build/index.js:111892:148)\n    at EventEmitter.<anonymous> (/triggerdotdev/apps/webapp/build/index.js:111794:23)\n    at EventEmitter.emit (node:events:518:28)\n    at Connection.<anonymous> (/triggerdotdev/apps/webapp/build/index.js:111558:23)\n    at Connection.emit (node:events:530:35)\n    at /triggerdotdev/node_modules/.pnpm/[email protected]/node_modules/pg/lib/connection.js:116:12\n    at Parser.parse (/triggerdotdev/node_modules/.pnpm/[email protected]/node_modules/pg-protocol/dist/parser.js:36:17)"},"origin":"unhandledRejection","timestamp":"2025-09-02T07:04:37.300Z","name":"webapp","message":"uncaughtException","level":"error"}

Original message: https://discord.com/channels/1066956501299777596/1287767734595092480/1412332657689366591


Testing

I had the bug and I wasn't able to start the webapp. After implementing this fix everything went fine again.


Changelog

Ensure that the run exists so it doesn't crash if not

💯

Copy link

changeset-bot bot commented Sep 10, 2025

⚠️ No Changeset found

Latest commit: 2d4991a

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

Copy link
Contributor

coderabbitai bot commented Sep 10, 2025

Walkthrough

Adds a guard in the batch-merge logic of runsReplicationService.server.ts to skip processing items where item.run or item.run.id is missing or null. When such a case is encountered, it logs a warning message ("Skipping replication event with null run") and proceeds to the next item. Existing merge behavior for valid items is unchanged. No exported/public API signatures are modified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The current pull request description omits the mandatory “Closes #” header from the template and substitutes it with a custom “## Issue” section, which does not align with the repository’s required structure; although the checklist, testing steps, and changelog are present, the issue linking section is missing and the headings diverge from the template. Please add a top-level “Closes #” line linking the relevant issue number, rename or remove the custom “## Issue” block to match the template’s format, and verify that the remaining sections (Testing, Changelog, and the optional Screenshots placeholder) use the exact headings and order specified in the repository’s description template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Fix: webapp crash on clickhouse data corruption” directly and concisely describes the main issue addressed by the changeset, namely preventing a crash in the webapp caused by null run IDs during replication of clickhouse data, without extraneous details or ambiguity. It clearly summarizes the primary fix and uses straightforward language that teammates can quickly scan and understand.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9b17e2 and 2d4991a.

📒 Files selected for processing (1)
  • apps/webapp/app/services/runsReplicationService.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/services/runsReplicationService.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/services/runsReplicationService.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/services/runsReplicationService.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/services/runsReplicationService.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/services/runsReplicationService.server.ts
⏰ 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). (22)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 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 (1, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: typecheck / typecheck
🔇 Additional comments (1)
apps/webapp/app/services/runsReplicationService.server.ts (1)

151-154: Good defensive guard to prevent null-run crashes.

This check avoids the item.run.id dereference panic seen in production. Nice.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

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.

2 participants