temporalio / sdk-typescript

Temporal TypeScript SDK
Other
540 stars 108 forks source link

[Feature Request] Support passing preloaded data converters to Client #1458

Open mjameswh opened 4 months ago

mjameswh commented 4 months ago

Describe the solution you'd like

At this time, all public APIs that accept DataConverters require payload converter and failure converter to be specified as paths. That requirement originally stemmed from a desire of being consistent with the way DataConverters are passed to Workflow Workers, where paths are required because these two converters need to be loaded inside the Workflow Sandbox.

It however appears that in this specific case, consistency is often counter-productive. Workflow code and client code are often part of distinct deployment units, with distinct build processes for workflow vs client code, so that’s already inconsistent. By imposing consistency, we are forcing users to adapt and complexify the build process of all non-Workflow Worker components without no real reason to do so.

Instead, we should make Client accept pre-loaded data converters. And possibly do the same for Activity-only Workers.

ilijaNL commented 2 months ago

Possible workaround for now is

const worker = await Worker.create({
    connection,
    dataConverter: await getDataConverter(),
    ...rest
  });

  const loadedDataConverter = worker.options.loadedDataConverter;
  if (loadedDataConverter)
    loadedDataConverter.failureConverter = new DefaultFailureConverter({
      encodeCommonAttributes: true,
    });