You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data-converter.md
+22-2Lines changed: 22 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -25,9 +25,17 @@ function workflowInclusiveInstanceOf(instance: unknown, type: Function): boolean
25
25
26
26
Given the possibility of switching or adding other isolation methods in future, we opted to convert to/from Payloads inside the vm (`PayloadConverter`). We also added another transformer layer called `PayloadCodec` that runs outside the vm, can use node async APIs (like `zlib.gzip` for compression or `crypto.scrypt` for encryption), and operates on Payloads. A `DataConverter` is a `PayloadConverter` and zero or more `PayloadCodec`s:
27
27
28
+
Later on (2022-09-22) we added a `FailureConverter` that is responsible to convert from proto `Failure` instances to JS
29
+
`Error`s and back. The failure converter runs inside the Workflow vm and may place failure attributes in the
30
+
[`Failure.encoded_attributes`][encoded_attributes]`Payload`. If that payload is present, it will be encoded / decoded
31
+
with the configured set of `PayloadCodec`s.
32
+
33
+
The SDK contains a "default" `FailureConverter` that can be configured to encode error messages and stack traces.
@@ -50,15 +63,22 @@ Temporal Server <--> Wire <--> `PayloadCodec` <--> `PayloadConverter` <--> User
50
63
51
64
`PayloadCodec` only runs in the main thread.
52
65
53
-
When `WorkerOptions.dataConverter.payloadConverterPath` is provided, the code at that location is loaded into the main thread and the webpack Workflow bundle.
66
+
When `WorkerOptions.dataConverter.payloadConverterPath` (or `failureConverterPath`) is provided, the code at that
67
+
location is loaded into the main thread and the webpack Workflow bundle.
54
68
55
69
`Worker.create`:
56
70
_main thread_
57
71
58
72
- imports and validates `options.dataConverter.payloadConverterPath`
73
+
- imports and validates `options.dataConverter.failureConverterPath`
59
74
- passes `payloadConverterPath` to `WorkflowCodeBundler`
60
75
61
76
`worker-interface.ts#initRuntime`:
62
77
_workflow vm_
63
78
64
-
- Imports `__temporal_custom_payload_converter`, which will either be the code bundled from `payloadConverterPath` or `undefined`. If it's defined, sets `state.payloadConverter`.
79
+
- Imports `__temporal_custom_payload_converter`, which will either be the code bundled from `payloadConverterPath` or
80
+
`undefined`. If it's defined, sets `state.payloadConverter`.
81
+
- Imports `__temporal_custom_failure_converter`, which will either be the code bundled from `failureConverterPath` or
82
+
`undefined`. If it's defined, sets `state.failureConverter`.
0 commit comments