@@ -4,12 +4,17 @@ import type {
44 ValidQueueName ,
55 World ,
66} from '@workflow/world' ;
7- import { HealthCheckPayloadSchema , SPEC_VERSION_CURRENT } from '@workflow/world' ;
7+ import {
8+ HealthCheckPayloadSchema ,
9+ SPEC_VERSION_CURRENT ,
10+ SPEC_VERSION_LEGACY ,
11+ } from '@workflow/world' ;
812import { monotonicFactory } from 'ulid' ;
913
1014import { runtimeLogger } from '../logger.js' ;
1115import * as Attribute from '../telemetry/semantic-conventions.js' ;
1216import { getSpanKind , trace } from '../telemetry.js' ;
17+ import { version as workflowCoreVersion } from '../version.js' ;
1318import { getWorld } from './world.js' ;
1419
1520/** Default timeout for health checks in milliseconds */
@@ -99,6 +104,7 @@ export async function handleHealthCheckMessage(
99104 endpoint,
100105 correlationId : healthCheck . correlationId ,
101106 specVersion : SPEC_VERSION_CURRENT ,
107+ workflowCoreVersion,
102108 timestamp : Date . now ( ) ,
103109 } ) ;
104110 // Use a fake runId that passes validation.
@@ -114,6 +120,8 @@ export type HealthCheckEndpoint = 'workflow' | 'step';
114120export interface HealthCheckOptions {
115121 /** Timeout in milliseconds to wait for health check response. Default: 30000 (30s) */
116122 timeout ?: number ;
123+ /** Deployment ID to send the health check to. Falls back to process.env.VERCEL_DEPLOYMENT_ID. */
124+ deploymentId ?: string ;
117125}
118126
119127/**
@@ -186,6 +194,12 @@ function parseHealthCheckResponse(
186194 try {
187195 response = JSON . parse ( responseText ) ;
188196 } catch {
197+ // Old deployments (specVersion < 3) return plain text like
198+ // 'Workflow SDK "..." endpoint is healthy'. Treat any non-empty
199+ // text response as a healthy deployment with unknown specVersion.
200+ if ( responseText . length > 0 ) {
201+ return { healthy : true } ;
202+ }
189203 return null ;
190204 }
191205
@@ -225,10 +239,16 @@ export async function healthCheck(
225239 const startTime = Date . now ( ) ;
226240
227241 try {
228- await world . queue ( queueName , {
229- __healthCheck : true ,
230- correlationId,
231- } ) ;
242+ await world . queue (
243+ queueName ,
244+ { __healthCheck : true , correlationId } ,
245+ {
246+ // Use JSON transport so the health check works against both
247+ // old (JSON-only) and new (dual) deployments.
248+ specVersion : SPEC_VERSION_LEGACY ,
249+ deploymentId : options ?. deploymentId ,
250+ }
251+ ) ;
232252
233253 while ( Date . now ( ) - startTime < timeout ) {
234254 try {
@@ -375,6 +395,7 @@ export function withHealthCheck(
375395 healthy : true ,
376396 endpoint : url . pathname ,
377397 specVersion : SPEC_VERSION_CURRENT ,
398+ workflowCoreVersion,
378399 } ) ,
379400 {
380401 status : 200 ,
0 commit comments