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