René's URL Explorer Experiment


Title: fix(webapp): recover from ClickHouse JSON parse failures in runs replication by matt-aitken · Pull Request #3708 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: fix(webapp): recover from ClickHouse JSON parse failures in runs replication by matt-aitken · Pull Request #3708 · triggerdotdev/trigger.dev

X Title: fix(webapp): recover from ClickHouse JSON parse failures in runs replication by matt-aitken · Pull Request #3708 · triggerdotdev/trigger.dev

Description: Summary On a ClickHouse Cannot parse JSON object rejection, RunsReplicationService now sanitizes lone UTF-16 surrogates across the failing batch via the existing sanitizeRows helper and retries once. If the sanitizer found nothing or the retry also fails, the batch is dropped loudly with a counter increment, so the surrounding #insertWithRetry layer doesn't spin three more times on a deterministic failure. Non-parse errors propagate unchanged. Mirrors the pattern from #3659 (for ClickhouseEventRepository) — same root cause (lone UTF-16 surrogates in user-provided JSON), same recovery shape, reusing the same shared helpers (sanitizeRows, isClickHouseJsonParseError, parseRowNumberFromError). Fixes the customer-facing symptom from TRI-9755: a single row's poisoned output JSON used to take down the COMPLETED_SUCCESSFULLY UPDATE events for its 50+ batch-mates, stranding them in EXECUTING in ClickHouse forever and inflating "Running" counts on the Tasks page. Confirmed in production this is ongoing — ~120k stale rows accumulated in a single 5-hour burst on 2026-05-18; smaller continuous leak before and after. What changed apps/webapp/app/services/runsReplicationService.server.ts: Imports the three helpers from ~/v3/eventRepository/sanitizeRowsOnParseError.server (no duplication; no move). New private #insertWithJsonParseRecovery(rows, doInsert, contextLabel, attempt) — generic over TaskRunInsertArray[] and PayloadInsertArray[], structurally identical to ClickhouseEventRepository.#insertWithJsonParseRecovery. Try → on parse error sanitize the whole batch (the at row N hint is logged but not used to slice — semantics under input_format_parallel_parsing aren't stable) → retry once → drop with loud log if sanitizer found nothing OR retry still fails. #insertTaskRunInserts and #insertPayloadInserts extract a doInsert closure and hand it to the wrapper. Existing error logging, span recording, and recordSpanError are preserved inside the closure. New private _permanentlyDroppedBatches = 0 counter with a public getter, for ops dashboards and tests (matches the events-repo convention). One shared counter for both insert sites — granularity comes from the contextLabel (task_runs_v2 / raw_task_runs_payload_v1) on every log line. .server-changes/runs-replication-utf16-recovery.md — release notes entry. Why no new tests The shared helpers already have full unit + real-ClickHouse contract coverage from #3659 (apps/webapp/test/sanitizeRowsOnParseError.test.ts, apps/webapp/test/otlpUtf16Sanitization.integration.test.ts). The new wrapper is a line-for-line structural port. Adding a parallel integration test would require synthesizing bad data that escapes the preemptive detectBadJsonStrings check in #prepareJson but still trips ClickHouse — non-trivial without hand-crafted fixtures and wouldn't cover any new logic. What this does NOT do Doesn't touch the ~120k existing stale EXECUTING rows in production. That needs a reconciliation/backfill sweep (separate ticket — TRI-9755 fix #3). Doesn't sanitize the error column path (runsReplicationService.server.ts:932 const errorData = { data: run.error };). Reactive recovery will catch it if it ever poisons a batch, but feeding it through #prepareJson like output is a cheap follow-up. Test plan pnpm run typecheck --filter webapp — clean Post-deploy: confirm permanentlyDroppedBatches counter stays at zero (or near-zero) in /stp/trigger-app-prod/ecs/replication/service-container/process-logs, and watch for Sanitizing batch after ClickHouse JSON parse error warns to confirm recovery is firing on real traffic Post-deploy: confirm the rate of new "EXECUTING-but-actually-COMPLETED" zombies in ClickHouse flattens (current rate ≈ tens-to-hundreds per hour platform-wide) 🤖 Generated with Claude Code

Open Graph Description: Summary On a ClickHouse Cannot parse JSON object rejection, RunsReplicationService now sanitizes lone UTF-16 surrogates across the failing batch via the existing sanitizeRows helper and retries onc...

X Description: Summary On a ClickHouse Cannot parse JSON object rejection, RunsReplicationService now sanitizes lone UTF-16 surrogates across the failing batch via the existing sanitizeRows helper and retries onc...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/3708

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:58d062b7-b4e5-0e96-0a72-85cdaaef82e5
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE182:18D292:2E5B96:4259C1:6AFAFDB6
html-safe-noncea5b0f6f9af0e8007a7a335860ba0b05c5d8f2f65291e1915f638638c34583275
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTgyOjE4RDI5MjoyRTVCOTY6NDI1OUMxOjZBRkFGREI2IiwidmlzaXRvcl9pZCI6IjUwNjM0MTIyNDIxMjA5MDAwMjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2391206991bceb6541a68ea192b9fc725c043c09cf70f856af47e072c92b1c56
hovercard-subject-tagpull_request:3731525265
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/3708/files
twitter:imagehttps://avatars.githubusercontent.com/u/10635986?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/10635986?s=400&v=4
og:image:altSummary On a ClickHouse Cannot parse JSON object rejection, RunsReplicationService now sanitizes lone UTF-16 surrogates across the failing batch via the existing sanitizeRows helper and retries onc...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None54f7a6886649661c85eee945cca0773566bfb4065370e0429b7c8f7204184650
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecf8450eb633ec589502c42ff6f4072e40db65da3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/3708/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F3708%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F3708%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3708/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3708/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3708/files
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests67 (67)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
matt-aitkenhttps://github.com/matt-aitken
mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
feature/tri-9755-runs-replication-silently-drops-batches-on-bad-output-jsonhttps://github.com/triggerdotdev/trigger.dev/tree/feature/tri-9755-runs-replication-silently-drops-batches-on-bad-output-json
Conversation 6 https://github.com/triggerdotdev/trigger.dev/pull/3708
Commits 2 https://github.com/triggerdotdev/trigger.dev/pull/3708/commits
Checks 33 https://github.com/triggerdotdev/trigger.dev/pull/3708/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/3708/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3708/files
fix(webapp): recover from ClickHouse JSON parse failures in runs replication https://github.com/triggerdotdev/trigger.dev/pull/3708/files#top
Show all changes 2 commits https://github.com/triggerdotdev/trigger.dev/pull/3708/files
8957a01 fix(webapp): recover from ClickHouse JSON parse failures in runs repl… matt-aitken May 22, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3708/commits/8957a01abf9f04f25e0b3dbbf17f99185ccd14e8
bea811a fix(webapp): don't count dropped batches as successful inserts in met… matt-aitken May 22, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3708/commits/bea811ac41d77d56996648a795be471069d2aed7
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/3708/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3708/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3708/files
runs-replication-utf16-recovery.md https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-901be564f20790d5d002ea94a3f6adffa5702b641f3b127d69a3da3489af0d22
runsReplicationService.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
.server-changes/runs-replication-utf16-recovery.mdhttps://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-901be564f20790d5d002ea94a3f6adffa5702b641f3b127d69a3da3489af0d22
View file https://github.com/triggerdotdev/trigger.dev/blob/bea811ac41d77d56996648a795be471069d2aed7/.server-changes/runs-replication-utf16-recovery.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3708/{{ revealButtonHref }}
apps/webapp/app/services/runsReplicationService.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
View file https://github.com/triggerdotdev/trigger.dev/blob/bea811ac41d77d56996648a795be471069d2aed7/apps/webapp/app/services/runsReplicationService.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3708/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com/triggerdotdev/trigger.dev/pull/3708/files#diff-57d6170ebedce17e6b4c66542bf89ca786d33ac432459f7e5cfec3bc7391e0b5
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.