Temporal server version 1.21.4
using Typescript SDK
@temporalio - 1.7.0
using node 16
Hello,
I’m trying to implement a sink, but when calling the sink function, I keep getting a DataCloneError
This seems to come from the first parameter of type WorkflowInfo for all sink functions. I tried my own custom sink, the example alert sink, and only the defaultLoggerSink.
The unsafe
property of WorkFlowInfo
, type UnsafeWorkflowInfo
has a property now()
. When postMessage
is called, it tries to serialize { isReplaying: false, now: [Function: now] }
which seems to cause the above error.
Not sure if I could be missing a step. I also tried following the example here https://github.com/temporalio/samples-typescript/blob/main/sinks/src/workflows.ts and kept it all in one file but still had this error.
my sink:
import { proxySinks, LoggerSinks, Sinks } from "@temporalio/workflow";
export interface CustomSinks extends Sinks {
tracer: { trace(): void };
logger: { log(): void };
}
export type WorkerSinks = CustomSinks & LoggerSinks;
creating the worker:
(async () => {
const sinks: InjectedSinks<WorkerSinks> = {
...defaultSinks(),
tracer: {
trace: {
fn() {
return;
},
},
},
logger: {
log: {
fn(workflowInfo) {
return;
},
callDuringReplay: true,
},
},
};
//bundling code omitted
const connection = await NativeConnection.connect({
address: TEMPORAL_SERVER_ADDRESS,
});
const worker = await Worker.create({
bundlerOptions,
...workflowCode,
activities,
taskQueue: TEMPORAL_WORKER_QUEUE,
sinks,
connection,
});
await worker.run();
})();
workflow:
const { logger } = proxySinks<WorkerSinks>();
export async function myWorkflow(
reqContext: ReqContext,
request: workflowArgs
) {
logger.log();
...