Skip to content

Commit 9d197d7

Browse files
yuandrewchris-olszewski
authored andcommitted
Revert "Worker heartbeating"
This reverts commit e09a2dc.
1 parent 42ff4f9 commit 9d197d7

File tree

6 files changed

+10
-83
lines changed

6 files changed

+10
-83
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,5 @@
102102
"node": ">= 18.0.0",
103103
"npm": ">= 7.0.0",
104104
"rustc": ">= 1.53.0"
105-
},
106-
"packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808"
105+
}
107106
}

packages/core-bridge/src/runtime.rs

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ macro_rules! enter_sync {
3636
pub fn init(cx: &mut neon::prelude::ModuleContext) -> neon::prelude::NeonResult<()> {
3737
cx.export_function("newRuntime", runtime_new)?;
3838
cx.export_function("runtimeShutdown", runtime_shutdown)?;
39-
// cx.export_function(
40-
// "runtimeGetWorkerHeartbeatIntervalMillis",
41-
// runtime_get_worker_heartbeat_interval_millis,
42-
// )?;
4339

4440
Ok(())
4541
}
@@ -55,7 +51,6 @@ pub struct Runtime {
5551
// For some unknown reason, the otel metrics exporter will go crazy on shutdown in some
5652
// scenarios if we don't hold on to the `CoreOtelMeter` till the `Runtime` finally gets dropped.
5753
_otel_metrics_exporter: Option<Arc<dyn CoreMeter + 'static>>,
58-
// worker_heartbeat_interval_millis: Option<u64>,
5954
}
6055

6156
/// Initialize Core global telemetry and create the tokio runtime required to run Core.
@@ -64,13 +59,11 @@ pub struct Runtime {
6459
pub fn runtime_new(
6560
bridge_options: config::RuntimeOptions,
6661
) -> BridgeResult<OpaqueOutboundHandle<Runtime>> {
67-
let (telemetry_options, metrics_options, logging_options, worker_heartbeat_interval_millis) =
68-
bridge_options.try_into()?;
62+
let (telemetry_options, metrics_options, logging_options) = bridge_options.try_into()?;
6963

7064
// Create core runtime which starts tokio multi-thread runtime
7165
let runtime_options = RuntimeOptionsBuilder::default()
7266
.telemetry_options(telemetry_options)
73-
.heartbeat_interval(worker_heartbeat_interval_millis.map(Duration::from_millis))
7467
.build()
7568
.context("Failed to build runtime options")?;
7669
let mut core_runtime = CoreRuntime::new(runtime_options, TokioRuntimeBuilder::default())
@@ -132,7 +125,6 @@ pub fn runtime_new(
132125
log_exporter_task,
133126
metrics_exporter_task: prom_metrics_exporter_task.map(Arc::new),
134127
_otel_metrics_exporter: otel_metrics_exporter,
135-
// worker_heartbeat_interval_millis: runtime_options.worker_heartbeat_interval.map(|d| d.as_millis() as u64),
136128
}))
137129
}
138130

@@ -146,21 +138,6 @@ pub fn runtime_shutdown(runtime: OpaqueInboundHandle<Runtime>) -> BridgeResult<(
146138
Ok(())
147139
}
148140

149-
// #[js_function]
150-
// pub fn runtime_get_worker_heartbeat_interval_millis(
151-
// runtime: OpaqueInboundHandle<Runtime>,
152-
// ) -> BridgeResult<Option<u32>> {
153-
// runtime
154-
// .borrow()?
155-
// .worker_heartbeat_interval_millis
156-
// .map(u32::try_from)
157-
// .transpose()
158-
// .map_err(|_| BridgeError::TypeError {
159-
// field: None,
160-
// message: "workerHeartbeatIntervalMillis is too large to represent in JavaScript".into(),
161-
// })
162-
// }
163-
164141
/// Drop will handle the cleanup
165142
impl MutableFinalize for Runtime {}
166143

@@ -288,7 +265,6 @@ mod config {
288265
log_exporter: LogExporterOptions,
289266
telemetry: TelemetryOptions,
290267
metrics_exporter: Option<MetricsExporterOptions>,
291-
worker_heartbeat_interval_millis: Option<u64>,
292268
}
293269

294270
#[derive(Debug, Clone, TryFromJs)]
@@ -345,7 +321,6 @@ mod config {
345321
CoreTelemetryOptions,
346322
Option<super::BridgeMetricsExporter>,
347323
super::BridgeLogExporter,
348-
Option<u64>,
349324
)> for RuntimeOptions
350325
{
351326
type Error = BridgeError;
@@ -355,16 +330,8 @@ mod config {
355330
CoreTelemetryOptions,
356331
Option<super::BridgeMetricsExporter>,
357332
super::BridgeLogExporter,
358-
Option<u64>,
359333
)> {
360-
let Self {
361-
log_exporter,
362-
telemetry,
363-
metrics_exporter,
364-
worker_heartbeat_interval_millis,
365-
} = self;
366-
367-
let (telemetry_logger, log_exporter) = match log_exporter {
334+
let (telemetry_logger, log_exporter) = match self.log_exporter {
368335
LogExporterOptions::Console { filter } => (
369336
CoreTelemetryLogger::Console { filter },
370337
BridgeLogExporter::Console,
@@ -384,21 +351,17 @@ mod config {
384351
let mut telemetry_options = TelemetryOptionsBuilder::default();
385352
let telemetry_options = telemetry_options
386353
.logging(telemetry_logger)
387-
.metric_prefix(telemetry.metric_prefix)
388-
.attach_service_name(telemetry.attach_service_name)
354+
.metric_prefix(self.telemetry.metric_prefix)
355+
.attach_service_name(self.telemetry.attach_service_name)
389356
.build()
390357
.context("Failed to build telemetry options")?;
391358

392-
let metrics_exporter = metrics_exporter
359+
let metrics_exporter = self
360+
.metrics_exporter
393361
.map(std::convert::TryInto::try_into)
394362
.transpose()?;
395363

396-
Ok((
397-
telemetry_options,
398-
metrics_exporter,
399-
log_exporter,
400-
worker_heartbeat_interval_millis,
401-
))
364+
Ok((telemetry_options, metrics_exporter, log_exporter))
402365
}
403366
}
404367

packages/core-bridge/src/worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub fn worker_complete_nexus_task(
295295
.complete_nexus_task(nexus_completion)
296296
.await
297297
.map_err(|err| match err {
298-
CompleteNexusError::NexusNotEnabled => {
298+
CompleteNexusError::NexusNotEnabled {} => {
299299
BridgeError::UnexpectedError(format!("{err}"))
300300
}
301301
CompleteNexusError::MalformedNexusCompletion { reason } => BridgeError::TypeError {

packages/core-bridge/ts/native.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ export type JsonString<_T> = string;
4040
// Runtime
4141
////////////////////////////////////////////////////////////////////////////////////////////////////
4242

43-
export declare function newRuntime(runtimeOptions: RuntimeOptions): Runtime;
43+
export declare function newRuntime(telemOptions: RuntimeOptions): Runtime;
4444

4545
export declare function runtimeShutdown(runtime: Runtime): void;
4646

47-
export declare function runtimeGetWorkerHeartbeatIntervalMillis(runtime: Runtime): number | null;
48-
4947
export interface Runtime {
5048
type: 'runtime';
5149
}
@@ -54,7 +52,6 @@ export type RuntimeOptions = {
5452
logExporter: LogExporterOptions;
5553
telemetry: TelemetryOptions;
5654
metricsExporter: MetricExporterOptions;
57-
workerHeartbeatIntervalMillis: Option<number>;
5855
};
5956

6057
export type TelemetryOptions = {

packages/test/src/test-bridge.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,20 +227,6 @@ test("Stopping Worker after creating another runtime doesn't fail", async (t) =>
227227
t.pass();
228228
});
229229

230-
test('Creating runtime with heartbeat enabled plumbs heartbeat duration', (t) => {
231-
const runtime = native.newRuntime({
232-
...GenericConfigs.runtime.basic,
233-
workerHeartbeatIntervalMillis: 100,
234-
});
235-
t.is(native.runtimeGetWorkerHeartbeatIntervalMillis(runtime), 100);
236-
237-
const runtime1 = native.newRuntime({
238-
...GenericConfigs.runtime.basic,
239-
workerHeartbeatIntervalMillis: null,
240-
});
241-
t.is(native.runtimeGetWorkerHeartbeatIntervalMillis(runtime1), null);
242-
});
243-
244230
// Sample configs ///////////////////////////////////////////////////////////////////////////////////
245231

246232
const GenericConfigs = {
@@ -255,7 +241,6 @@ const GenericConfigs = {
255241
attachServiceName: false,
256242
},
257243
metricsExporter: null,
258-
workerHeartbeatIntervalMillis: null,
259244
} satisfies native.RuntimeOptions,
260245
},
261246
client: {

packages/worker/src/runtime-options.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ export interface RuntimeOptions {
3232
*/
3333
telemetryOptions?: TelemetryOptions;
3434

35-
/**
36-
* Interval for worker heartbeats. `null` disables heartbeating.
37-
*
38-
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
39-
* @default 60000 (60 seconds)
40-
*/
41-
workerHeartbeatInterval?: Duration | null;
42-
4335
/**
4436
* Automatically shutdown workers on any of these signals.
4537
*
@@ -375,14 +367,6 @@ export function compileOptions(options: RuntimeOptions): CompiledRuntimeOptions
375367
const { metrics, noTemporalPrefixForMetrics } = options.telemetryOptions ?? {}; // eslint-disable-line deprecation/deprecation
376368
const [logger, logExporter] = compileLoggerOptions(options);
377369

378-
// Handle worker heartbeat interval - default to 60s, allow null to disable
379-
let workerHeartbeatIntervalMillis: number | null;
380-
if (options.workerHeartbeatInterval === null) {
381-
workerHeartbeatIntervalMillis = null;
382-
} else {
383-
workerHeartbeatIntervalMillis = msToNumber(options.workerHeartbeatInterval ?? '60s');
384-
}
385-
386370
return {
387371
logger,
388372
shutdownSignals: options.shutdownSignals ?? ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGUSR2'],
@@ -392,7 +376,6 @@ export function compileOptions(options: RuntimeOptions): CompiledRuntimeOptions
392376
metricPrefix: metrics?.metricPrefix ?? (noTemporalPrefixForMetrics ? '' : 'temporal_'),
393377
attachServiceName: metrics?.attachServiceName ?? true,
394378
},
395-
workerHeartbeatIntervalMillis,
396379
metricsExporter:
397380
metrics && isPrometheusMetricsExporter(metrics)
398381
? ({

0 commit comments

Comments
 (0)