(
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;
},
)
| 3274 | }); |
| 3275 | |
| 3276 | const connectionCheckHealth = ( |
| 3277 | ref: ConnectionRef, |
| 3278 | options?: { |
| 3279 | /** Skip the probe and return the persisted verdict when it is younger |
| 3280 | * than this. The server owns the freshness decision so N open tabs |
| 3281 | * revalidating on load cannot stampede an upstream. Omit = always |
| 3282 | * probe (the manual "Check now"). */ |
| 3283 | readonly ifStaleMs?: number; |
| 3284 | }, |
| 3285 | ): Effect.Effect< |
| 3286 | HealthCheckResult, |
| 3287 | ConnectionNotFoundError | IntegrationNotFoundError | StorageFailure |
| 3288 | > => |
| 3289 | Effect.gen(function* () { |
| 3290 | const connectionRow = yield* findConnectionRow(ref); |
| 3291 | if (!connectionRow) { |
| 3292 | return yield* new ConnectionNotFoundError({ |
| 3293 | owner: ref.owner, |
| 3294 | integration: ref.integration, |
| 3295 | name: ref.name, |
| 3296 | }); |
| 3297 | } |
| 3298 | if (options?.ifStaleMs !== undefined) { |
| 3299 | const cached = Option.getOrNull(decodeLastHealth(connectionRow.last_health)); |
| 3300 | if (cached && Date.now() - cached.checkedAt < options.ifStaleMs) { |
| 3301 | yield* annotateHealthVerdict("cache", cached); |
| 3302 | return cached; |
| 3303 | } |
| 3304 | } |
| 3305 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 3306 | if (!integrationRow) { |
| 3307 | return yield* new IntegrationNotFoundError({ slug: ref.integration }); |
| 3308 | } |
| 3309 | const runtime = runtimes.get(integrationRow.plugin_id); |
| 3310 | const check = runtime?.plugin.checkHealth; |
| 3311 | if (!runtime || !check) { |
| 3312 | const result = unknownHealth(); |
| 3313 | yield* annotateHealthVerdict("no_capability", result); |
| 3314 | return result; |
| 3315 | } |
| 3316 | const spec = describeHealthCheckForRow(integrationRow) ?? undefined; |
| 3317 | if (spec === undefined && connectionRow.oauth_client != null) { |
| 3318 | // No probe operation is declared, so "healthy" here means only "the |
| 3319 | // credential resolved (refreshing if due)" — a refresh failure is |
| 3320 | // the one real signal this path can produce, and it must not hide |
| 3321 | // inside a green span. |
| 3322 | const result = yield* oauthCredentialHealthWithoutProbe(connectionRow); |
| 3323 | yield* annotateHealthVerdict("credential_only", result); |
| 3324 | yield* persistHealthResult(ref, result); |
| 3325 | return result; |
| 3326 | } |
| 3327 | |
| 3328 | const result = yield* Effect.gen(function* () { |
| 3329 | const values = yield* resolveConnectionValues(connectionRow); |
| 3330 | const record = rowToIntegrationRecord( |
| 3331 | integrationRow, |
| 3332 | describeAuthMethodsForRow(integrationRow), |
| 3333 | ); |
nothing calls this directly
no test coverage detected