(
ref: ConnectionRef,
options?: {
/** Skip the probe and return the persisted verdict when it is younger
* than this. The server owns the freshness decision so N open tabs
* revalidating on load cannot stampede an upstream. Omit = always
* probe (the manual "Check now"). */
readonly ifStaleMs?: number;
},
)
| 3193 | }); |
| 3194 | |
| 3195 | const connectionCheckHealth = ( |
| 3196 | ref: ConnectionRef, |
| 3197 | options?: { |
| 3198 | /** Skip the probe and return the persisted verdict when it is younger |
| 3199 | * than this. The server owns the freshness decision so N open tabs |
| 3200 | * revalidating on load cannot stampede an upstream. Omit = always |
| 3201 | * probe (the manual "Check now"). */ |
| 3202 | readonly ifStaleMs?: number; |
| 3203 | }, |
| 3204 | ): Effect.Effect< |
| 3205 | HealthCheckResult, |
| 3206 | ConnectionNotFoundError | IntegrationNotFoundError | StorageFailure |
| 3207 | > => |
| 3208 | Effect.gen(function* () { |
| 3209 | const connectionRow = yield* findConnectionRow(ref); |
| 3210 | if (!connectionRow) { |
| 3211 | return yield* new ConnectionNotFoundError({ |
| 3212 | owner: ref.owner, |
| 3213 | integration: ref.integration, |
| 3214 | name: ref.name, |
| 3215 | }); |
| 3216 | } |
| 3217 | if (options?.ifStaleMs !== undefined) { |
| 3218 | const cached = Option.getOrNull(decodeLastHealth(connectionRow.last_health)); |
| 3219 | if (cached && Date.now() - cached.checkedAt < options.ifStaleMs) { |
| 3220 | yield* annotateHealthVerdict("cache", cached); |
| 3221 | return cached; |
| 3222 | } |
| 3223 | } |
| 3224 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 3225 | if (!integrationRow) { |
| 3226 | return yield* new IntegrationNotFoundError({ slug: ref.integration }); |
| 3227 | } |
| 3228 | const runtime = runtimes.get(integrationRow.plugin_id); |
| 3229 | const check = runtime?.plugin.checkHealth; |
| 3230 | if (!runtime || !check) { |
| 3231 | const result = unknownHealth(); |
| 3232 | yield* annotateHealthVerdict("no_capability", result); |
| 3233 | return result; |
| 3234 | } |
| 3235 | const spec = describeHealthCheckForRow(integrationRow) ?? undefined; |
| 3236 | if (spec === undefined && connectionRow.oauth_client != null) { |
| 3237 | // No probe operation is declared, so "healthy" here means only "the |
| 3238 | // credential resolved (refreshing if due)" — a refresh failure is |
| 3239 | // the one real signal this path can produce, and it must not hide |
| 3240 | // inside a green span. |
| 3241 | const result = yield* oauthCredentialHealthWithoutProbe(connectionRow); |
| 3242 | yield* annotateHealthVerdict("credential_only", result); |
| 3243 | yield* persistHealthResult(ref, result); |
| 3244 | return result; |
| 3245 | } |
| 3246 | |
| 3247 | const result = yield* Effect.gen(function* () { |
| 3248 | const values = yield* resolveConnectionValues(connectionRow); |
| 3249 | const record = rowToIntegrationRecord( |
| 3250 | integrationRow, |
| 3251 | describeAuthMethodsForRow(integrationRow), |
| 3252 | ); |
nothing calls this directly
no test coverage detected