Skip to content

perf(builder): optimize build pipeline and gate types in CI - #945

Merged
realcodesiman merged 5 commits into
mainfrom
perf/builder-build-optimization
Aug 13, 2026
Merged

realcodesiman merged 5 commits into
mainfrom
perf/builder-build-optimization

Conversation

@realcodesiman

@realcodesiman realcodesiman commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace parallel routes (@channel/@integration slots) with dynamic segments + a shared RouteAccordionShell, cutting the route permutations Next.js has to compile for settings/channels and settings/integrations
  • Disable in-build type-checking (typescript.ignoreBuildErrors) since the duplicated tsc pass OOMs a default 4GB heap; add .github/workflows/ci.yml and a check gate in release.yml so turbo run check-types lint test is the one source of truth for types
  • Add BuildKit cache mounts (pnpm store, .next/cache) and optional Turbo remote-cache secrets to the Docker build, restored via buildkit-cache-dance in release.yml
  • Guard module-scope Redis/Postgres/auth initialization during next build's page-data collection phase (no services reachable then): lazyConnect on the worker-config Redis client, static trustedOrigins, parseEnvBool for logger flags that skip zod coercion under SKIP_ENV_CHECK=true
  • Bump next 16.3.0-canary.81 → 16.3.0 (stable) and related lockfile updates
  • Fix CI timeouts caused by turbo's default 10-way task concurrency plus one vitest worker per CPU fighting for the runner's 4 vCPUs: cap turbo run check-types lint test at --concurrency=4, pin vitest maxWorkers=1 on CI, and raise testTimeout/hookTimeout to 30s
  • Backfill missing translation keys (added by earlier ads/permissions features) across all non-English locales so the i18n key-parity check passes

Changes

  • Routing refactor: apps/builder/src/app/space/[workspaceId]/(settings)/settings/{channels,integrations}/ — parallel-route slots converted to <channel>/page.tsx dynamic routes; new channels-accordion-shell.tsx, integrations-accordion-shell.tsx, shared src/components/route-accordion-shell.tsx, src/lib/workspace/resolve-visible-channels.ts, src/lib/workspace/require-visible-channel.ts, src/features/integrations/settings-registry.ts
  • Build/CI: new .github/workflows/ci.yml (now with --concurrency=4); release.yml type-check gate + BuildKit cache-mount restore/inject; apps/builder/docker/Dockerfile cache mounts; apps/builder/next.config.ts (ignoreBuildErrors, optimizePackageImports); turbo.json passThroughEnv; .dockerignore broadened .next/.turbo ignores; packages/vitest-config/src/node.ts (maxWorkers=1 on CI, 30s test/hook timeouts)
  • Build-phase safety: packages/auth/src/server.ts (static trustedOrigins during build), packages/database/src/client.ts + packages/utils/src/env.ts (parseEnvBool), packages/worker-config/src/lib/connection.ts + packages/redis/src/index.ts (lazyConnect/createRedisConnection)
  • Test stabilization: hoisted a heavy dynamic import out of a per-test timeout window (account-rail.test.tsx), added a missing createRedisConnection mock (ads-conversion-rule.service.test.ts), dropped now-redundant per-test 15s timeouts in analytics tests
  • i18n: all 17 non-English locale files backfilled with keys already present in en.json (errors.superAdminRequired, ctwa*, etc.)
  • Docs/skills: AGENTS.md, CLAUDE.md, docs/tenancy.md, .agents/skills/*, .devin/rules/chatbotx.md, .github/copilot-instructions.md synced to reflect the above
  • New tests: settings-tab-active-state.test.ts, trusted-origins-build-phase.test.ts, connection-build-phase.test.ts, env.test.ts; updated channel-route-guard/visibility tests for the dynamic-route shape

Test plan

  • pnpm lint
  • pre-commit hooks (ultracite fix, typecheck) passed
  • pnpm --filter builder check-types
  • CI workflow (ci.yml) green on this PR, no timeouts
  • Manual verification: settings/channels and settings/integrations pages render and navigate correctly per channel/integration
  • Docker build completes with BuildKit cache mounts locally or in CI

realcodesiman and others added 3 commits August 13, 2026 17:17
- Replace parallel routes (@channel/@integration slots) with dynamic
  segments + a shared RouteAccordionShell, cutting route permutations
  next.js has to compile for settings/channels and settings/integrations
- Disable in-build type-checking (typescript.ignoreBuildErrors) since the
  duplicated tsc pass OOMs a default 4GB heap; add ci.yml and a release.yml
  gate so `turbo run check-types lint test` stays the one source of truth
- Add BuildKit cache mounts (pnpm store, .next/cache) and optional Turbo
  remote cache secrets to the Docker build, restored via
  buildkit-cache-dance in release.yml
- Guard module-scope Redis/Postgres/auth initialization during
  `next build`'s page-data collection phase (no services reachable then):
  lazyConnect on the worker-config Redis client, static trustedOrigins,
  parseEnvBool for logger flags that skip zod coercion under
  SKIP_ENV_CHECK=true
- Bump next 16.3.0-canary.81 -> 16.3.0 (stable) and related lockfile updates
Floating v2 tag can move to a breaking release without warning;
pin the exact version used in ci.yml and release.yml.
…timizing builds

Broadens db-client mocks across builder/worker tests to include columns
read eagerly at module scope by the contact-filter/variables import
chain, so tests don't depend on unmocked initializers. Also fixes an
encryption AAD precedence bug, an Instagram private-reply endpoint that
addressed the Page node instead of the IG business account, and adds a
Popover `portal` opt-out used by ComboboxField's allowClear support.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
… timeouts

Turbo's default of 10 concurrent tasks combined with one vitest worker
per CPU multiplied into dozens of node processes fighting for the
runner's 4 vCPUs, pushing cold module-graph imports past the 5s test
timeout. Caps turbo at --concurrency=4, pins vitest to maxWorkers=1 on
CI, and raises testTimeout/hookTimeout to 30s so a slow import doesn't
poison the next test in the same file. Also fixes cross-cutting bugs
surfaced while chasing the flakiness: a missing createRedisConnection
mock, hoisting a heavy dynamic import out of a per-test timeout budget,
and dropping now-redundant per-test 15s timeouts.
CI's i18n key-parity check requires every locale to carry the same key
set as en.json. Keys added by earlier ads/permissions features
(ctwa*, errors.superAdminRequired, etc.) were never backfilled into
non-English locales, so this fills the gap.
@realcodesiman
realcodesiman merged commit 8b6a0c5 into main Aug 13, 2026
15 checks passed
@realcodesiman
realcodesiman deleted the perf/builder-build-optimization branch August 13, 2026 16:38
viethung0o0 pushed a commit that referenced this pull request Sep 7, 2026
* perf(builder): optimize build pipeline and gate types in CI

- Replace parallel routes (@channel/@integration slots) with dynamic
  segments + a shared RouteAccordionShell, cutting route permutations
  next.js has to compile for settings/channels and settings/integrations
- Disable in-build type-checking (typescript.ignoreBuildErrors) since the
  duplicated tsc pass OOMs a default 4GB heap; add ci.yml and a release.yml
  gate so `turbo run check-types lint test` stays the one source of truth
- Add BuildKit cache mounts (pnpm store, .next/cache) and optional Turbo
  remote cache secrets to the Docker build, restored via
  buildkit-cache-dance in release.yml
- Guard module-scope Redis/Postgres/auth initialization during
  `next build`'s page-data collection phase (no services reachable then):
  lazyConnect on the worker-config Redis client, static trustedOrigins,
  parseEnvBool for logger flags that skip zod coercion under
  SKIP_ENV_CHECK=true
- Bump next 16.3.0-canary.81 -> 16.3.0 (stable) and related lockfile updates

* ci: pin caching-for-turbo action to v2.5.1

Floating v2 tag can move to a breaking release without warning;
pin the exact version used in ci.yml and release.yml.

* fix(tests): stabilize mocks and fix cross-cutting bugs found while optimizing builds

Broadens db-client mocks across builder/worker tests to include columns
read eagerly at module scope by the contact-filter/variables import
chain, so tests don't depend on unmocked initializers. Also fixes an
encryption AAD precedence bug, an Instagram private-reply endpoint that
addressed the Page node instead of the IG business account, and adds a
Popover `portal` opt-out used by ComboboxField's allowClear support.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(ci): reduce turbo concurrency and vitest worker fan-out to fix CI timeouts

Turbo's default of 10 concurrent tasks combined with one vitest worker
per CPU multiplied into dozens of node processes fighting for the
runner's 4 vCPUs, pushing cold module-graph imports past the 5s test
timeout. Caps turbo at --concurrency=4, pins vitest to maxWorkers=1 on
CI, and raises testTimeout/hookTimeout to 30s so a slow import doesn't
poison the next test in the same file. Also fixes cross-cutting bugs
surfaced while chasing the flakiness: a missing createRedisConnection
mock, hoisting a heavy dynamic import out of a per-test timeout budget,
and dropping now-redundant per-test 15s timeouts.

* chore(i18n): backfill missing translation keys across all locales

CI's i18n key-parity check requires every locale to carry the same key
set as en.json. Keys added by earlier ads/permissions features
(ctwa*, errors.superAdminRequired, etc.) were never backfilled into
non-English locales, so this fills the gap.

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
sung17 added a commit that referenced this pull request Sep 9, 2026
…#1122)

sendPrivateReplyMessage posted to `{igId}/messages`, which Meta rejects with
`(#3) Application does not have the capability to make this API call.` even when
the app holds instagram_manage_messages, pages_messaging and Human Agent at
Advanced Access. For Instagram via Facebook Login the `messages` edge only
exists on the Page node, so every private reply on that channel failed: the
automation's `text` and `AIAgent` replies, the first message of a `flow` reply,
and the agent's manual private reply from the inbox.

This is the second time the fix has been needed. #875 moved the endpoint to
`pageId`, then #945 moved it back to green a stale test whose fixture carried no
`pageId` at all — so the endpoint silently became `/undefined/messages` and the
assertion on the IG node kept passing. The test is now the guard instead of the
cause: the fixture carries a `pageId` distinct from `igId`, and a new case
asserts the IG node is never called.

Also guards a missing `pageId` explicitly rather than building
`/undefined/messages`, which is the silent failure mode that hid the regression.

Two adjacent error-mapping bugs surfaced while tracing this:

- Code 3 was in neither Instagram mapper, so it fell through to the
  `type === "OAuthException"` fallback and was reported as AUTH_FAILED —
  pointing operators at a reconnect that could never help. It is a capability
  problem, so it now maps to PERMISSION_DENIED (permanent), as messenger
  already does.
- instagram-facebook's isRevokedTokenError matched *any* OAuthException,
  including code 3, making the disconnect flow skip its remote teardown for
  unrelated errors. Narrowed to code 190 plus a revoked subcode, matching the
  Instagram Login variant, which excludes a bare 190 as ambiguous to avoid
  false-positive disconnects.

Unrelated, found in the same log: the getProfile failure in received-message.ts
logged under `error`, so pino dropped the stack trace. Keyed to `err`.

Co-authored-by: Deathgiver <[email protected]>
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
… (#1122)

sendPrivateReplyMessage posted to `{igId}/messages`, which Meta rejects with
`(#3) Application does not have the capability to make this API call.` even when
the app holds instagram_manage_messages, pages_messaging and Human Agent at
Advanced Access. For Instagram via Facebook Login the `messages` edge only
exists on the Page node, so every private reply on that channel failed: the
automation's `text` and `AIAgent` replies, the first message of a `flow` reply,
and the agent's manual private reply from the inbox.

This is the second time the fix has been needed. #875 moved the endpoint to
`pageId`, then #945 moved it back to green a stale test whose fixture carried no
`pageId` at all — so the endpoint silently became `/undefined/messages` and the
assertion on the IG node kept passing. The test is now the guard instead of the
cause: the fixture carries a `pageId` distinct from `igId`, and a new case
asserts the IG node is never called.

Also guards a missing `pageId` explicitly rather than building
`/undefined/messages`, which is the silent failure mode that hid the regression.

Two adjacent error-mapping bugs surfaced while tracing this:

- Code 3 was in neither Instagram mapper, so it fell through to the
  `type === "OAuthException"` fallback and was reported as AUTH_FAILED —
  pointing operators at a reconnect that could never help. It is a capability
  problem, so it now maps to PERMISSION_DENIED (permanent), as messenger
  already does.
- instagram-facebook's isRevokedTokenError matched *any* OAuthException,
  including code 3, making the disconnect flow skip its remote teardown for
  unrelated errors. Narrowed to code 190 plus a revoked subcode, matching the
  Instagram Login variant, which excludes a bare 190 as ambiguous to avoid
  false-positive disconnects.

Unrelated, found in the same log: the getProfile failure in received-message.ts
logged under `error`, so pino dropped the stack trace. Keyed to `err`.

Co-authored-by: Deathgiver <[email protected]>

This branch was previously deployed

1 inactive deployment
dev — 4d745207 Deployed Aug 13, 2026 by realcodesiman via Build worker #2377
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Refactor or performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant