type holyshared = Engineer<mixed>

技術的なことなど色々

OCamlのduneでSegmentatiob faultになる問題が解決した

原因はmacOSのバージョンとmacOS SDKのバージョンの不一致が原因だった。 macOS SDKのバージョンは27だったけど、macOSは26系だった。

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 27.0.0.0.1788430756
volume: /
location: /
install-time: 1789177480

以前のビルドは macOS 27 SDK 向けで、pipe2 と dup3 が NULL になり、Unix.pipe を呼ぶとクラッシュしていました。
Unix.pipeはmacOS 27 SDKを利用した場合、pipe2()を使用する形でコンパイルされますが、macOS 26はpipe2()がないので、NULL になる weak シンボルとして扱いました。

なのでmacOSを27(Golden Gate)にアップグレードして、OCamlコンパイラ、duneを再インストールだけでSegmentatiob faultで落ちることはなくなりました。

OCamlでduneを使用したビルドがSegmentation faultで失敗する

OCamlのコードをコンパイルしたくて、duneでビルドをしようとしたらビルド時にSegmentation faultで失敗しました。
コンパイラのバージョンを下げたりしても起きるのでduneの問題ぽいことがわかりました。

macOS Tahoe 26.6.2で、OCaml周りの各バージョンは下記の通りで、--verboseオプションをつけて詳細を探ろうとしましたたが、新しく出る情報は特になかったです。

ocamlc -version
ocamlopt -version
opam --version
3.24.2
5.5.1
5.5.1
2.6.0
dune build --verbose
zsh: segmentation fault  dune build --verbose

次に並列オプションを1にしてビルドを試すと成功したので、並列ビルド周りが怪しそうということが分かりました。

dune clean
dune build -j 1 --verbose
Shared cache enabled cache_enabled: Enabled_except_user_rules
Shared cache location root_dir: "/Users/noritaka.horio/.cache/dune/db"
Workspace root root: "/Users/noritaka.horio/Documents/projects/ocaml-scrap/example_effect"
Dune context context: { name = "default"
; kind = "default"
; profile = Dev
; merlin = true
; fdo_target_exe = None
; build_dir = In_build_dir "default"
; instrument_with = []
}
Running[1]: (cd _build/default && /Users/noritaka.horio/.opam/5.5.1/bin/ocamlc.opt -w @1..3@5..28@31..39@43@46..47@49..57@61..62@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -bin-annot-occurrences -I bin/.main.eobjs/byte -no-alias-deps -opaque -o bin/.main.eobjs/byte/dune__exe__Main.cmi -c -intf bin/main.mli)
Running[2]: (cd _build/default && /Users/noritaka.horio/.opam/5.5.1/bin/ocamlopt.opt -w @1..3@5..28@31..39@43@46..47@49..57@61..62@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -I bin/.main.eobjs/byte -I bin/.main.eobjs/native -cmi-file bin/.main.eobjs/byte/dune__exe__Main.cmi -no-alias-deps -opaque -o bin/.main.eobjs/native/dune__exe__Main.cmx -c -impl bin/main.ml)
Running[3]: (cd _build/default && /Users/noritaka.horio/.opam/5.5.1/bin/ocamlopt.opt -w @1..3@5..28@31..39@43@46..47@49..57@61..62@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -o bin/main.exe bin/.main.eobjs/native/dune__exe__Main.cmx)

duneの場合、何並列にするかはコア数を見て判断しているので、コア数を確認して試してみると成功しました。
なので、並列数を指定しない場合に問題起きていることがわかりました。

sysctl -n hw.ncpu
sysctl -n hw.logicalcpu
sysctl -n hw.physicalcpu
8
8
8

dune build -j 8

ヘルプを見る限り、並列数を指定しない場合、autoを渡したのと同じ振る舞いになるらしいので、autoを指定してみるとSegmentation faultになり、コアの自動検出部分に問題があることがわかりました。

-j JOBS (absent DUNE_JOBS env)
  Run no more than JOBS commands simultaneously. JOBS must be a
   positive integer or auto to auto-detect the number of cores (the
   default).


dune clean
dune build -j auto --verbose
zsh: segmentation fault  dune build -j auto --verbose

問題のあたりはついたのだけど、ビルドしたいだけでデバックしたいわけではないので一旦環境変数を指定して対応することにしました。

export DUNE_JOBS=8

余裕があったら調べたいです。

2026-10-18の追加調査

Duneの場合OSがWindowsでない場合は、nproc, getconfを使用してコア数を取得しています。
nprocはmacOSでは標準で入っていないはずなので、次のgetconfを利用した処理が走るようです。

         let commands =
           [ "nproc", []
           ; "getconf", [ "_NPROCESSORS_ONLN" ]
           ; "getconf", [ "NPROCESSORS_ONLN" ]
           ]
         in
         let rec loop = function
           | [] -> 1
           | (prog, args) :: rest ->
             (match Bin.which ~path:(Env_path.path Env.initial) prog with
              | None -> loop rest
              | Some prog ->
                let prog = Path.to_string prog in
                let fdr, fdw = Unix.pipe () ~cloexec:true in
                let fdw = Fd.unsafe_of_unix_file_descr fdw in

RenovateでGitHub ActionsのNodejsのMatrix設定を更新できるようにした

Renovateで依存関係を更新する様にしていたのですが、Dockerのベースイメージや依存パッケージは更新できるのですが、GitHub Actionsのstrategy.matrixはデフォルトではできないので、設定を追加しました。

name: Build packages

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  api-test:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: ["26.10.0"] # <-- ここの指定を更新したい

RenovateではcustomManagersを使用します
具体的にはcustomTypeでregexを指定し、managerFilePatternsで対象のファイルを指定します

また、バージョンを確認するデータソースやバージョンの比較方法も追加で設定します

  • datasourceTemplate: バージョンをどこで確認するかのデータソース
  • depNameTemplate: 依存関係の名前
    • 依存関係の名前はキャプチャの <depName> を使用せず、nodeにします
  • versioningTemplate: バージョンの比較
{
  "customManagers": [
    {
      "customType": "regex",
      "description": "GitHub Actions の strategy.matrix.node-version を更新する",
      "managerFilePatterns": [
        "/^\\.github/workflows/.*\\.ya?ml$/"
      ],
      "matchStrings": [
        "node-version:\\s*\\[\\s*\"(?<currentValue>[^\"]+)\"\\s*\\]"
      ],
      "datasourceTemplate": "node-version",
      "depNameTemplate": "node",
      "versioningTemplate": "node"
    }
  ],
}

これでバージョンが更新できると思います

Renovateのkernel-out-of-memoryを直す

Renovateのジョブがkernel-out-of-memoryで落ちていて、依存関係の更新が止まっていました。
ログは yarn install --mode=update-lockfile の実行開始直後で途切れていて、カーネルにkillされていた様です。

ローカルでコールドキャッシュの場合で確認したところ、ピーク時で3.0〜3.8 GBのメモリを使用している感じだったので、Mend-hosted Renovate のデフォルト割り当ての3GBを yarn がそのまま食い潰していそうでした。

RenovateのFaqを見るとnodeMaxMemoryを設定するとよさそうでした。 docs.renovatebot.com

なのでRenovateの設定ファイルにnodeMaxMemoryを指定して、子プロセスの最大メモリ制限を設定しました。

{
  "toolSettings": {
    "nodeMaxMemory": 2048
  }
}

またMend のスケジューラは OOM で終了したリポジトリを weekly Blocked に降格させます。
なので設定をマージしただけでは次回実行まで待たされるので、Dependency Dashboard の「Check this box to trigger a request for Renovate to run again」にチェックを入れて手動実行します。

Dependency Dashboard

アプリケーションをCloud Deployでデプロイできる様にした

これまでは staging と production でそれぞれ別々にコンテナイメージをビルドし、環境ごとにデプロイしていました。 これを Cloud Deploy のデリバリーパイプラインに置き換え、1 つのイメージを staging にデプロイしてから production にプロモーションする形に変更しました。 その過程でやったことを、次の 3 つに分けてまとめます。

  1. コンテナイメージを staging/production の両方で動作させる
  2. Cloud Deploy でイメージをデプロイする
  3. デプロイ前にデータベースのマイグレーションを実行する

コンテナをstaging/production環境で動作させるようにする

staging から production へプロモーションするには、同じコンテナイメージが両方の環境で動作する必要があります。 そのため、ビルド時に値が解決されてイメージに埋め込まれてしまう VITE_ などの環境変数の利用をやめ、実行時に解決するようにしました。

あわせて Cloud Build の定義を staging/production のプロジェクトから CI/CD 用のプロジェクトへ移し、コンテナイメージのビルドを一本化しました。

旧ビルド

  • staging プロジェクト - develop に push されたら api/admin/web のイメージをビルドする
  • production プロジェクト - タグが push されたら api/admin/web のイメージをビルドする

新ビルド

  • CI/CD プロジェクト - タグが push されたら api/admin/web のイメージをマルチステージビルドでまとめてビルドする

ビルド方法を変更したあと、実際に Cloud Build でイメージをビルドし、staging/production の両環境でイメージを差し替えて正常に動作することを確認しました。

Cloud Deployでイメージをデプロイできる様にする

Cloud Deploy からイメージを差し替えると Terraform の管理する状態と食い違ってしまうため、まず Terraform 側の Cloud Run サービス定義でイメージの差分を無視するようにしました。 そのうえで Cloud Deploy のデリバリーパイプラインを定義します。 ターゲットは staging と production の 2 つで、staging から production へのデプロイには承認を必要としました。

Cloud Deploy には Cloud Run 向けの標準ターゲットもありますが、これを使うとサービスの定義そのものを Cloud Deploy 側のマニフェストで管理することになります。 Cloud Run の設定は Terraform で管理したいので、標準ターゲットは使わずカスタムターゲットを定義し、render と deploy の 2 つのタスクを自前のシェルスクリプトで実装しました。 render ではデプロイ対象のイメージを列挙したマニフェストを生成し、deploy ではそのイメージで Cloud Run のサービスを更新します。 Cloud Deploy にはイメージの差し替えだけを任せる形です。

カスタムターゲットの定義

resource "google_clouddeploy_custom_target_type" "cloud_run" {
  project     = var.project_id
  location    = var.region
  name        = "cloud-run-services"
  description = "Update the image tag of the Cloud Run services managed by Terraform"

  tasks {
    render {
      container {
        image   = "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
        command = ["/bin/bash", "-c"]
        args    = [file("${path.module}/scripts/render.sh")]
        env = {
          ARTIFACT_REPOSITORY = local.artifact_repository
          SERVICE_IMAGES      = "api-service=api,admin-service=admin,web-service=web" # サービス名=イメージをカンマ区切りで指定
        }
      }
    }

    deploy {
      container {
        image   = "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
        command = ["/bin/bash", "-c"]
        args    = [file("${path.module}/scripts/deploy.sh")]
        env = {
          ARTIFACT_REPOSITORY = local.artifact_repository
          SERVICE_IMAGES      = "api-service=api,admin-service=admin,web-service=web" # サービス名=イメージをカンマ区切りで指定
        }
      }
    }
  }

  depends_on = [
    google_project_iam_member.deploy
  ]
}

render.sh

#!/usr/bin/env bash

# render.sh

set -uo pipefail

workdir="$(mktemp -d)"
cd "${workdir}" || exit 1

: "${ARTIFACT_REPOSITORY:?ARTIFACT_REPOSITORY is required}"
: "${SERVICE_IMAGES:?SERVICE_IMAGES is required}"
: "${CLOUD_DEPLOY_customTarget_imageTag:?customTarget/imageTag deploy parameter is required}"

tag="${CLOUD_DEPLOY_customTarget_imageTag}"

{
  echo "# generated by Cloud Deploy render task"
  echo "imageTag: ${tag}"
  echo "services:"
  IFS=',' read -r -a pairs <<< "${SERVICE_IMAGES}"
  for pair in "${pairs[@]}"; do
    echo "  - service: ${pair%%=*}"
    echo "    image: ${ARTIFACT_REPOSITORY}/${pair#*=}:${tag}"
  done
} > manifest.yaml

cat manifest.yaml

gcloud storage cp manifest.yaml "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}/manifest.yaml" || exit 1

printf '{"resultStatus":"SUCCEEDED","manifestFile":"%s/manifest.yaml"}\n' \
  "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}" > results.json
gcloud storage cp results.json "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}/results.json"

deploy.sh

#!/usr/bin/env bash

# deploy.sh

set -uo pipefail

workdir="$(mktemp -d)"
cd "${workdir}" || exit 1

write_result() {
  if [ -n "${2:-}" ]; then
    printf '{"resultStatus":"%s","failureMessage":"%s"}\n' "$1" "$2" > results.json
  else
    printf '{"resultStatus":"%s"}\n' "$1" > results.json
  fi
  gcloud storage cp results.json "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}/results.json"
}

fail() {
  echo "$1" >&2
  write_result FAILED "$1"
  exit 1
}

: "${ARTIFACT_REPOSITORY:?ARTIFACT_REPOSITORY is required}"
: "${SERVICE_IMAGES:?SERVICE_IMAGES is required}"
: "${CLOUD_DEPLOY_customTarget_imageTag:?customTarget/imageTag deploy parameter is required}"
: "${CLOUD_DEPLOY_customTarget_runProject:?customTarget/runProject deploy parameter is required}"
: "${CLOUD_DEPLOY_customTarget_runRegion:?customTarget/runRegion deploy parameter is required}"

tag="${CLOUD_DEPLOY_customTarget_imageTag}"
run_project="${CLOUD_DEPLOY_customTarget_runProject}"
run_region="${CLOUD_DEPLOY_customTarget_runRegion}"

#
# Cloud Run サービスの更新
#
IFS=',' read -r -a pairs <<< "${SERVICE_IMAGES}"
for pair in "${pairs[@]}"; do
  service="${pair%%=*}"
  image="${ARTIFACT_REPOSITORY}/${pair#*=}:${tag}"

  echo "==> ${service}: ${image}"
  gcloud run services update "${service}" \
    --project="${run_project}" \
    --region="${run_region}" \
    --image="${image}" \
    --quiet || fail "failed to update Cloud Run service ${service} to ${image}"
done

write_result SUCCEEDED

デプロイ前にデータベースのマイグレーションできるようにする

deploy タスクをシェルスクリプトで実装したので、Cloud Run のサービスを更新する前にデータベースのマイグレーションを実行するようにしました。

具体的には、Cloud Run にマイグレーション用のジョブを追加し、deploy タスクの中でサービスのイメージを差し替える前にそのジョブを実行します。 ジョブが正常に完了したときだけ、サービスのイメージを新しいものに更新します。

ジョブのイメージには API サーバーのコンテナイメージを、サービスアカウントには API サーバーに割り当てているものをそのまま流用しました。 API サーバーと同じ権限でマイグレーションを実行することで、新しいテーブルを作成したときにテーブルのオーナーが食い違う様な問題が起きないようにしています。

カスタムターゲットの定義

resource "google_clouddeploy_custom_target_type" "cloud_run" {
  project     = var.project_id
  location    = var.region
  name        = "cloud-run-services"
  description = "Update the image tag of the Cloud Run services managed by Terraform"

  tasks {
    render {
      container {
        image   = "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
        command = ["/bin/bash", "-c"]
        args    = [file("${path.module}/scripts/render.sh")]
        env = {
          ARTIFACT_REPOSITORY = local.artifact_repository
          SERVICE_IMAGES      = "api-service=api,admin-service=admin,web-service=web" # サービス名=イメージをカンマ区切りで指定
          MIGRATION_JOB       = "db-migrate"
          MIGRATION_IMAGE     = "api" # apiのコンテナイメージを利用する
        }
      }
    }

    deploy {
      container {
        image   = "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
        command = ["/bin/bash", "-c"]
        args    = [file("${path.module}/scripts/deploy.sh")]
        env = {
          ARTIFACT_REPOSITORY = local.artifact_repository
          SERVICE_IMAGES      = "api-service=api,admin-service=admin,web-service=web" # サービス名=イメージをカンマ区切りで指定
          MIGRATION_JOB       = "db-migrate"
          MIGRATION_IMAGE     = "api" # apiのコンテナイメージを利用する
        }
      }
    }
  }

  depends_on = [
    google_project_iam_member.deploy
  ]
}

render.sh

#!/usr/bin/env bash

# render.sh

set -uo pipefail

workdir="$(mktemp -d)"
cd "${workdir}" || exit 1

: "${ARTIFACT_REPOSITORY:?ARTIFACT_REPOSITORY is required}"
: "${SERVICE_IMAGES:?SERVICE_IMAGES is required}"
: "${MIGRATION_JOB:?MIGRATION_JOB is required}"
: "${MIGRATION_IMAGE:?MIGRATION_IMAGE is required}"
: "${CLOUD_DEPLOY_customTarget_imageTag:?customTarget/imageTag deploy parameter is required}"

tag="${CLOUD_DEPLOY_customTarget_imageTag}"

{
  echo "# generated by Cloud Deploy render task"
  echo "imageTag: ${tag}"
  echo "migration:"
  echo "  job: ${MIGRATION_JOB}"
  echo "  image: ${ARTIFACT_REPOSITORY}/${MIGRATION_IMAGE}:${tag}"
  echo "services:"
  IFS=',' read -r -a pairs <<< "${SERVICE_IMAGES}"
  for pair in "${pairs[@]}"; do
    echo "  - service: ${pair%%=*}"
    echo "    image: ${ARTIFACT_REPOSITORY}/${pair#*=}:${tag}"
  done
} > manifest.yaml

cat manifest.yaml

gcloud storage cp manifest.yaml "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}/manifest.yaml" || exit 1

printf '{"resultStatus":"SUCCEEDED","manifestFile":"%s/manifest.yaml"}\n' \
  "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}" > results.json
gcloud storage cp results.json "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}/results.json"

deploy.sh

#!/usr/bin/env bash

# deploy.sh

set -uo pipefail

workdir="$(mktemp -d)"
cd "${workdir}" || exit 1

write_result() {
  if [ -n "${2:-}" ]; then
    printf '{"resultStatus":"%s","failureMessage":"%s"}\n' "$1" "$2" > results.json
  else
    printf '{"resultStatus":"%s"}\n' "$1" > results.json
  fi
  gcloud storage cp results.json "${CLOUD_DEPLOY_OUTPUT_GCS_PATH}/results.json"
}

fail() {
  echo "$1" >&2
  write_result FAILED "$1"
  exit 1
}

: "${ARTIFACT_REPOSITORY:?ARTIFACT_REPOSITORY is required}"
: "${SERVICE_IMAGES:?SERVICE_IMAGES is required}"
: "${MIGRATION_JOB:?MIGRATION_JOB is required}"
: "${MIGRATION_IMAGE:?MIGRATION_IMAGE is required}"
: "${CLOUD_DEPLOY_customTarget_imageTag:?customTarget/imageTag deploy parameter is required}"
: "${CLOUD_DEPLOY_customTarget_runProject:?customTarget/runProject deploy parameter is required}"
: "${CLOUD_DEPLOY_customTarget_runRegion:?customTarget/runRegion deploy parameter is required}"

tag="${CLOUD_DEPLOY_customTarget_imageTag}"
run_project="${CLOUD_DEPLOY_customTarget_runProject}"
run_region="${CLOUD_DEPLOY_customTarget_runRegion}"

#
# 1. DB マイグレーション
# 
migration_image="${ARTIFACT_REPOSITORY}/${MIGRATION_IMAGE}:${tag}"

echo "==> migration ${MIGRATION_JOB}: ${migration_image}"
gcloud run jobs update "${MIGRATION_JOB}" \
  --project="${run_project}" \
  --region="${run_region}" \
  --image="${migration_image}" \
  --quiet || fail "failed to update Cloud Run job ${MIGRATION_JOB} to ${migration_image}"

# --wait は実行が終わるまでブロックし、タスクが失敗すると非 0 で終了する
gcloud run jobs execute "${MIGRATION_JOB}" \
  --project="${run_project}" \
  --region="${run_region}" \
  --wait \
  --quiet || fail "database migration failed. see the logs of the Cloud Run job ${MIGRATION_JOB} in ${run_project}"

#
# 2. Cloud Run サービスの更新
#
IFS=',' read -r -a pairs <<< "${SERVICE_IMAGES}"
for pair in "${pairs[@]}"; do
  service="${pair%%=*}"
  image="${ARTIFACT_REPOSITORY}/${pair#*=}:${tag}"

  echo "==> ${service}: ${image}"
  gcloud run services update "${service}" \
    --project="${run_project}" \
    --region="${run_region}" \
    --image="${image}" \
    --quiet || fail "failed to update Cloud Run service ${service} to ${image}"
done

write_result SUCCEEDED

React Router v8のミドルウェア

React Router v7からv8に対応させる作業をやっていた。 一部のものだけログイン画面でログインしようとして、リダイレクトを繰り返す様になってしまったので調査と修正をした。

ログイン画面があるものは、v8で有効になるミドルウェアをfutureフラグで対応していて、これを消すだけくらいかなと思っていました。

// react-router.config.ts
export default {
  appDirectory: "src/app",
  ssr: true,
  buildDirectory: "dist"
  buildDirectory: "dist",
  // このフラグを消す
  future: {
    v8_middleware: true,
  },
} satisfies Config;

しかし、ローカルで試すとログイン前にミドルウェアで認証状態の確認を行っている箇所に引っかかってログイン画面にリダイレクトする処理が何度も実行される様になってしまいました。

原因はsingle fetchの挙動が変わったことが原因の様でした。 url.pathnameの末尾に.dataが付くパターンがあり(具体的にはaction)、そのせいで未認証のチェックに引っかかり、無限にリダイレクトするということが起きていました。

これはパスの末尾に.dataがついていることも考慮に入れることで解決しました。 ミドルウェアがloader, actionで実行されることを意識すれば解決しそうな話でした。

import { redirect } from "react-router";
import { getSession, destroySession } from "~/session";
import { type RouterContextProvider } from "react-router";
import { userContext } from "~/context";

export const authMiddleware = async ({
  request,
  context,
}: {
  request: Request;
  context: Readonly<RouterContextProvider>;
}) => {
  const url = new URL(request.url);
  const ctx = context.get(userContext);

  // React Router の single fetch ではデータリクエストのパスが `/sign_in.data`
  // のようになるため、`.data` を除去してから判定する
  const pathname = url.pathname.replace(/\.data$/, "");

  if (pathname === "/sign_in") {
    if (request.method === "GET" && ctx.user) {
      throw redirect("/");
    }
    return;
  }

  if (!ctx.user) {
    const session = await getSession(request.headers.get("Cookie"));
    throw redirect("/sign_in", {
      headers: {
        "Set-Cookie": await destroySession(session),
      },
    });
  }
};

TypeORM 1.0へアップグレードする

TypeORMが1.0になりました。
このため、0.3系から1.0にアップグレートを行いました。

やったことは接続のオプションの型指定と検索時のリレーションの指定方法です。

コネクションの型指定をPostgresConnectionOptionsからPostgresDataSourceOptionsに変更する

変更前

import type { PostgresConnectionOptions } from "typeorm/driver/postgres/PostgresConnectionOptions";

const defaultOptions: PostgresConnectionOptions = {
  type: "postgres",
  database: "example",
  entities: [User],
  synchronize: false,
  logging: true,
  migrations: ["./migrations/*{.ts,.js}"]
};

変更後

import type { PostgresDataSourceOptions } from "typeorm/driver/postgres/PostgresDataSourceOptions";

const defaultOptions: PostgresDataSourceOptions = {
  type: "postgres",
  database: "example",
  entities: [User],
  synchronize: false,
  logging: true,
  migrations: ["./migrations/*{.ts,.js}"]
};

relationsの指定をオブジェクト指定に置き換える

変更前

const results = await repo.findAndCount({
  where: {
    id: "id"
  },
  relations: ["group", "group.owner"]
});

変更後

const results = await repo.findAndCount({
  where: {
    id: "id"
  },
  relations: {
    group: {
      owner: true,
    },
  }
});