@temporalio/core-bridge 1.13.0 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/Cargo.lock +239 -382
  2. package/Cargo.toml +11 -11
  3. package/lib/native.d.ts +10 -3
  4. package/package.json +3 -3
  5. package/releases/aarch64-apple-darwin/index.node +0 -0
  6. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  7. package/releases/x86_64-apple-darwin/index.node +0 -0
  8. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  9. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  10. package/sdk-core/.cargo/config.toml +71 -11
  11. package/sdk-core/.clippy.toml +1 -0
  12. package/sdk-core/.github/workflows/heavy.yml +2 -0
  13. package/sdk-core/.github/workflows/per-pr.yml +50 -18
  14. package/sdk-core/ARCHITECTURE.md +44 -48
  15. package/sdk-core/Cargo.toml +26 -7
  16. package/sdk-core/README.md +4 -0
  17. package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
  18. package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
  19. package/sdk-core/arch_docs/sdks_intro.md +299 -0
  20. package/sdk-core/client/Cargo.toml +8 -7
  21. package/sdk-core/client/src/callback_based.rs +1 -2
  22. package/sdk-core/client/src/lib.rs +485 -299
  23. package/sdk-core/client/src/metrics.rs +32 -8
  24. package/sdk-core/client/src/proxy.rs +124 -5
  25. package/sdk-core/client/src/raw.rs +598 -307
  26. package/sdk-core/client/src/replaceable.rs +253 -0
  27. package/sdk-core/client/src/retry.rs +9 -6
  28. package/sdk-core/client/src/worker_registry/mod.rs +19 -3
  29. package/sdk-core/client/src/workflow_handle/mod.rs +20 -17
  30. package/sdk-core/core/Cargo.toml +100 -31
  31. package/sdk-core/core/src/core_tests/activity_tasks.rs +55 -225
  32. package/sdk-core/core/src/core_tests/mod.rs +2 -8
  33. package/sdk-core/core/src/core_tests/queries.rs +3 -5
  34. package/sdk-core/core/src/core_tests/replay_flag.rs +3 -62
  35. package/sdk-core/core/src/core_tests/updates.rs +4 -5
  36. package/sdk-core/core/src/core_tests/workers.rs +4 -3
  37. package/sdk-core/core/src/core_tests/workflow_cancels.rs +10 -7
  38. package/sdk-core/core/src/core_tests/workflow_tasks.rs +28 -291
  39. package/sdk-core/core/src/ephemeral_server/mod.rs +15 -3
  40. package/sdk-core/core/src/internal_flags.rs +11 -1
  41. package/sdk-core/core/src/lib.rs +50 -36
  42. package/sdk-core/core/src/pollers/mod.rs +5 -5
  43. package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
  44. package/sdk-core/core/src/protosext/mod.rs +13 -5
  45. package/sdk-core/core/src/protosext/protocol_messages.rs +4 -11
  46. package/sdk-core/core/src/retry_logic.rs +256 -108
  47. package/sdk-core/core/src/telemetry/metrics.rs +1 -0
  48. package/sdk-core/core/src/telemetry/mod.rs +8 -2
  49. package/sdk-core/core/src/telemetry/prometheus_meter.rs +2 -2
  50. package/sdk-core/core/src/test_help/integ_helpers.rs +971 -0
  51. package/sdk-core/core/src/test_help/mod.rs +10 -1100
  52. package/sdk-core/core/src/test_help/unit_helpers.rs +218 -0
  53. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +42 -6
  54. package/sdk-core/core/src/worker/activities/local_activities.rs +19 -19
  55. package/sdk-core/core/src/worker/activities.rs +10 -3
  56. package/sdk-core/core/src/worker/client/mocks.rs +3 -3
  57. package/sdk-core/core/src/worker/client.rs +130 -93
  58. package/sdk-core/core/src/worker/heartbeat.rs +12 -13
  59. package/sdk-core/core/src/worker/mod.rs +31 -21
  60. package/sdk-core/core/src/worker/nexus.rs +14 -3
  61. package/sdk-core/core/src/worker/slot_provider.rs +9 -0
  62. package/sdk-core/core/src/worker/tuner.rs +159 -0
  63. package/sdk-core/core/src/worker/workflow/history_update.rs +3 -265
  64. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -54
  65. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -82
  66. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -67
  67. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -192
  68. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -43
  69. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +6 -554
  70. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -71
  71. package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +102 -3
  72. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +10 -539
  73. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -139
  74. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -119
  75. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -63
  76. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +9 -4
  77. package/sdk-core/core/src/worker/workflow/mod.rs +5 -1
  78. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +8 -3
  79. package/sdk-core/core-api/Cargo.toml +4 -4
  80. package/sdk-core/core-api/src/envconfig.rs +153 -54
  81. package/sdk-core/core-api/src/lib.rs +68 -0
  82. package/sdk-core/core-api/src/telemetry/metrics.rs +2 -1
  83. package/sdk-core/core-api/src/telemetry.rs +13 -0
  84. package/sdk-core/core-c-bridge/Cargo.toml +13 -8
  85. package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +184 -22
  86. package/sdk-core/core-c-bridge/src/client.rs +462 -184
  87. package/sdk-core/core-c-bridge/src/envconfig.rs +314 -0
  88. package/sdk-core/core-c-bridge/src/lib.rs +1 -0
  89. package/sdk-core/core-c-bridge/src/random.rs +4 -4
  90. package/sdk-core/core-c-bridge/src/runtime.rs +22 -23
  91. package/sdk-core/core-c-bridge/src/testing.rs +1 -4
  92. package/sdk-core/core-c-bridge/src/tests/context.rs +31 -31
  93. package/sdk-core/core-c-bridge/src/tests/mod.rs +32 -28
  94. package/sdk-core/core-c-bridge/src/tests/utils.rs +7 -7
  95. package/sdk-core/core-c-bridge/src/worker.rs +319 -66
  96. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +6 -1
  97. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +5 -5
  98. package/sdk-core/sdk/Cargo.toml +8 -2
  99. package/sdk-core/sdk/src/activity_context.rs +1 -1
  100. package/sdk-core/sdk/src/app_data.rs +1 -1
  101. package/sdk-core/sdk/src/interceptors.rs +1 -4
  102. package/sdk-core/sdk/src/lib.rs +1 -5
  103. package/sdk-core/sdk/src/workflow_context/options.rs +10 -1
  104. package/sdk-core/sdk/src/workflow_future.rs +1 -1
  105. package/sdk-core/sdk-core-protos/Cargo.toml +6 -6
  106. package/sdk-core/sdk-core-protos/build.rs +10 -23
  107. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +9 -1
  108. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +254 -5
  109. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +234 -5
  110. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
  111. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
  112. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
  113. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
  114. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
  115. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
  116. package/sdk-core/{test-utils → sdk-core-protos}/src/canned_histories.rs +5 -5
  117. package/sdk-core/sdk-core-protos/src/history_builder.rs +2 -2
  118. package/sdk-core/sdk-core-protos/src/lib.rs +25 -9
  119. package/sdk-core/sdk-core-protos/src/test_utils.rs +89 -0
  120. package/sdk-core/sdk-core-protos/src/utilities.rs +14 -5
  121. package/sdk-core/tests/c_bridge_smoke_test.c +10 -0
  122. package/sdk-core/tests/cloud_tests.rs +10 -8
  123. package/sdk-core/tests/common/http_proxy.rs +134 -0
  124. package/sdk-core/{test-utils/src/lib.rs → tests/common/mod.rs} +214 -281
  125. package/sdk-core/{test-utils/src → tests/common}/workflows.rs +4 -3
  126. package/sdk-core/tests/fuzzy_workflow.rs +1 -1
  127. package/sdk-core/tests/global_metric_tests.rs +8 -7
  128. package/sdk-core/tests/heavy_tests.rs +7 -3
  129. package/sdk-core/tests/integ_tests/client_tests.rs +111 -24
  130. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +14 -9
  131. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +4 -4
  132. package/sdk-core/tests/integ_tests/metrics_tests.rs +114 -14
  133. package/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
  134. package/sdk-core/tests/integ_tests/polling_tests.rs +311 -93
  135. package/sdk-core/tests/integ_tests/queries_tests.rs +4 -4
  136. package/sdk-core/tests/integ_tests/update_tests.rs +13 -7
  137. package/sdk-core/tests/integ_tests/visibility_tests.rs +26 -9
  138. package/sdk-core/tests/integ_tests/worker_tests.rs +668 -13
  139. package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +40 -24
  140. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +244 -11
  141. package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
  142. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +78 -2
  143. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +61 -2
  144. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +465 -7
  145. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +41 -2
  146. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +315 -3
  147. package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
  148. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1990 -14
  149. package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +65 -2
  150. package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +123 -23
  151. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +525 -3
  152. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +65 -16
  153. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +32 -23
  154. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +126 -5
  155. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +1 -2
  156. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +124 -8
  157. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +62 -2
  158. package/sdk-core/tests/integ_tests/workflow_tests.rs +67 -8
  159. package/sdk-core/tests/main.rs +26 -17
  160. package/sdk-core/tests/manual_tests.rs +5 -1
  161. package/sdk-core/tests/runner.rs +22 -40
  162. package/sdk-core/tests/shared_tests/mod.rs +1 -1
  163. package/sdk-core/tests/shared_tests/priority.rs +1 -1
  164. package/sdk-core/{core/benches/workflow_replay.rs → tests/workflow_replay_bench.rs} +10 -5
  165. package/src/client.rs +97 -20
  166. package/src/helpers/callbacks.rs +4 -4
  167. package/src/helpers/errors.rs +7 -1
  168. package/src/helpers/handles.rs +1 -0
  169. package/src/helpers/try_from_js.rs +4 -3
  170. package/src/lib.rs +3 -2
  171. package/src/metrics.rs +3 -0
  172. package/src/runtime.rs +5 -2
  173. package/src/worker.rs +9 -12
  174. package/ts/native.ts +13 -3
  175. package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
  176. package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
  177. package/sdk-core/core/src/core_tests/determinism.rs +0 -318
  178. package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
  179. package/sdk-core/test-utils/Cargo.toml +0 -38
  180. package/sdk-core/test-utils/src/histfetch.rs +0 -28
  181. package/sdk-core/test-utils/src/interceptors.rs +0 -46
@@ -1,318 +0,0 @@
1
- use crate::{
2
- internal_flags::CoreInternalFlags,
3
- replay::DEFAULT_WORKFLOW_TYPE,
4
- test_help::{MockPollCfg, ResponseType, canned_histories, mock_sdk, mock_sdk_cfg},
5
- worker::client::mocks::mock_worker_client,
6
- };
7
- use std::{
8
- sync::atomic::{AtomicBool, AtomicUsize, Ordering},
9
- time::Duration,
10
- };
11
- use temporal_client::WorkflowOptions;
12
- use temporal_sdk::{
13
- ActivityOptions, ChildWorkflowOptions, LocalActivityOptions, WfContext, WorkflowResult,
14
- };
15
- use temporal_sdk_core_protos::{
16
- DEFAULT_ACTIVITY_TYPE, TestHistoryBuilder,
17
- temporal::api::{
18
- enums::v1::{EventType, WorkflowTaskFailedCause},
19
- failure::v1::Failure,
20
- },
21
- };
22
-
23
- static DID_FAIL: AtomicBool = AtomicBool::new(false);
24
-
25
- pub(crate) async fn timer_wf_fails_once(ctx: WfContext) -> WorkflowResult<()> {
26
- ctx.timer(Duration::from_secs(1)).await;
27
- if DID_FAIL
28
- .compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
29
- .is_ok()
30
- {
31
- panic!("Ahh");
32
- }
33
- Ok(().into())
34
- }
35
-
36
- /// Verifies that workflow panics (which in this case the Rust SDK turns into workflow activation
37
- /// failures) are turned into unspecified WFT failures.
38
- #[tokio::test]
39
- async fn test_panic_wf_task_rejected_properly() {
40
- let wf_id = "fakeid";
41
- let wf_type = DEFAULT_WORKFLOW_TYPE;
42
- let t = canned_histories::workflow_fails_with_failure_after_timer("1");
43
- let mock = mock_worker_client();
44
- let mut mh = MockPollCfg::from_resp_batches(wf_id, t, [1, 2, 2], mock);
45
- // We should see one wft failure which has unspecified cause, since panics don't have a defined
46
- // type.
47
- mh.num_expected_fails = 1;
48
- mh.expect_fail_wft_matcher =
49
- Box::new(|_, cause, _| matches!(cause, WorkflowTaskFailedCause::Unspecified));
50
- let mut worker = mock_sdk(mh);
51
-
52
- worker.register_wf(wf_type.to_owned(), timer_wf_fails_once);
53
- worker
54
- .submit_wf(
55
- wf_id.to_owned(),
56
- wf_type.to_owned(),
57
- vec![],
58
- WorkflowOptions::default(),
59
- )
60
- .await
61
- .unwrap();
62
- worker.run_until_done().await.unwrap();
63
- }
64
-
65
- /// Verifies nondeterministic behavior in workflows results in automatic WFT failure with the
66
- /// appropriate nondeterminism cause.
67
- #[rstest::rstest]
68
- #[case::with_cache(true)]
69
- #[case::without_cache(false)]
70
- #[tokio::test]
71
- async fn test_wf_task_rejected_properly_due_to_nondeterminism(#[case] use_cache: bool) {
72
- let wf_id = "fakeid";
73
- let wf_type = DEFAULT_WORKFLOW_TYPE;
74
- let t = canned_histories::single_timer_wf_completes("1");
75
- let mock = mock_worker_client();
76
- let mut mh = MockPollCfg::from_resp_batches(
77
- wf_id,
78
- t,
79
- // Two polls are needed, since the first will fail
80
- [ResponseType::AllHistory, ResponseType::AllHistory],
81
- mock,
82
- );
83
- // We should see one wft failure which has nondeterminism cause
84
- mh.num_expected_fails = 1;
85
- mh.expect_fail_wft_matcher =
86
- Box::new(|_, cause, _| matches!(cause, WorkflowTaskFailedCause::NonDeterministicError));
87
- let mut worker = mock_sdk_cfg(mh, |cfg| {
88
- if use_cache {
89
- cfg.max_cached_workflows = 2;
90
- }
91
- });
92
-
93
- let started_count: &'static _ = Box::leak(Box::new(AtomicUsize::new(0)));
94
- worker.register_wf(wf_type.to_owned(), move |ctx: WfContext| async move {
95
- // The workflow is replaying all of history, so the when it schedules an extra timer it
96
- // should not have, it causes a nondeterminism error.
97
- if started_count.fetch_add(1, Ordering::Relaxed) == 0 {
98
- ctx.timer(Duration::from_secs(1)).await;
99
- }
100
- ctx.timer(Duration::from_secs(1)).await;
101
- Ok(().into())
102
- });
103
-
104
- worker
105
- .submit_wf(
106
- wf_id.to_owned(),
107
- wf_type.to_owned(),
108
- vec![],
109
- WorkflowOptions::default(),
110
- )
111
- .await
112
- .unwrap();
113
- worker.run_until_done().await.unwrap();
114
- // Started count is two since we start, restart once due to error, then we unblock the real
115
- // timer and proceed without restarting
116
- assert_eq!(2, started_count.load(Ordering::Relaxed));
117
- }
118
-
119
- #[rstest::rstest]
120
- #[tokio::test]
121
- async fn activity_id_or_type_change_is_nondeterministic(
122
- #[values(true, false)] use_cache: bool,
123
- #[values(true, false)] id_change: bool,
124
- #[values(true, false)] local_act: bool,
125
- ) {
126
- let wf_id = "fakeid";
127
- let wf_type = DEFAULT_WORKFLOW_TYPE;
128
- let mut t: TestHistoryBuilder = if local_act {
129
- canned_histories::single_local_activity("1")
130
- } else {
131
- canned_histories::single_activity("1")
132
- };
133
- t.set_flags_first_wft(&[CoreInternalFlags::IdAndTypeDeterminismChecks as u32], &[]);
134
- let mock = mock_worker_client();
135
- let mut mh = MockPollCfg::from_resp_batches(
136
- wf_id,
137
- t,
138
- // Two polls are needed, since the first will fail
139
- [ResponseType::AllHistory, ResponseType::AllHistory],
140
- mock,
141
- );
142
- // We should see one wft failure which has nondeterminism cause
143
- mh.num_expected_fails = 1;
144
- mh.expect_fail_wft_matcher = Box::new(move |_, cause, f| {
145
- let should_contain = if id_change {
146
- "does not match activity id"
147
- } else {
148
- "does not match activity type"
149
- };
150
- matches!(cause, WorkflowTaskFailedCause::NonDeterministicError)
151
- && matches!(f, Some(Failure {
152
- message,
153
- ..
154
- }) if message.contains(should_contain))
155
- });
156
- let mut worker = mock_sdk_cfg(mh, |cfg| {
157
- if use_cache {
158
- cfg.max_cached_workflows = 2;
159
- }
160
- });
161
-
162
- worker.register_wf(wf_type.to_owned(), move |ctx: WfContext| async move {
163
- if local_act {
164
- ctx.local_activity(if id_change {
165
- LocalActivityOptions {
166
- activity_id: Some("I'm bad and wrong!".to_string()),
167
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
168
- ..Default::default()
169
- }
170
- } else {
171
- LocalActivityOptions {
172
- activity_type: "not the default act type".to_string(),
173
- ..Default::default()
174
- }
175
- })
176
- .await;
177
- } else {
178
- ctx.activity(if id_change {
179
- ActivityOptions {
180
- activity_id: Some("I'm bad and wrong!".to_string()),
181
- activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
182
- ..Default::default()
183
- }
184
- } else {
185
- ActivityOptions {
186
- activity_type: "not the default act type".to_string(),
187
- ..Default::default()
188
- }
189
- })
190
- .await;
191
- }
192
- Ok(().into())
193
- });
194
-
195
- worker
196
- .submit_wf(
197
- wf_id.to_owned(),
198
- wf_type.to_owned(),
199
- vec![],
200
- WorkflowOptions::default(),
201
- )
202
- .await
203
- .unwrap();
204
- worker.run_until_done().await.unwrap();
205
- }
206
-
207
- #[rstest::rstest]
208
- #[tokio::test]
209
- async fn child_wf_id_or_type_change_is_nondeterministic(
210
- #[values(true, false)] use_cache: bool,
211
- #[values(true, false)] id_change: bool,
212
- ) {
213
- let wf_id = "fakeid";
214
- let wf_type = DEFAULT_WORKFLOW_TYPE;
215
- let mut t = canned_histories::single_child_workflow("1");
216
- t.set_flags_first_wft(&[CoreInternalFlags::IdAndTypeDeterminismChecks as u32], &[]);
217
- let mock = mock_worker_client();
218
- let mut mh = MockPollCfg::from_resp_batches(
219
- wf_id,
220
- t,
221
- // Two polls are needed, since the first will fail
222
- [ResponseType::AllHistory, ResponseType::AllHistory],
223
- mock,
224
- );
225
- // We should see one wft failure which has nondeterminism cause
226
- mh.num_expected_fails = 1;
227
- mh.expect_fail_wft_matcher = Box::new(move |_, cause, f| {
228
- let should_contain = if id_change {
229
- "does not match child workflow id"
230
- } else {
231
- "does not match child workflow type"
232
- };
233
- matches!(cause, WorkflowTaskFailedCause::NonDeterministicError)
234
- && matches!(f, Some(Failure {
235
- message,
236
- ..
237
- }) if message.contains(should_contain))
238
- });
239
- let mut worker = mock_sdk_cfg(mh, |cfg| {
240
- if use_cache {
241
- cfg.max_cached_workflows = 2;
242
- }
243
- });
244
-
245
- worker.register_wf(wf_type.to_owned(), move |ctx: WfContext| async move {
246
- ctx.child_workflow(if id_change {
247
- ChildWorkflowOptions {
248
- workflow_id: "I'm bad and wrong!".to_string(),
249
- workflow_type: DEFAULT_ACTIVITY_TYPE.to_string(),
250
- ..Default::default()
251
- }
252
- } else {
253
- ChildWorkflowOptions {
254
- workflow_id: "1".to_string(),
255
- workflow_type: "not the child wf type".to_string(),
256
- ..Default::default()
257
- }
258
- })
259
- .start(&ctx)
260
- .await;
261
- Ok(().into())
262
- });
263
-
264
- worker
265
- .submit_wf(
266
- wf_id.to_owned(),
267
- wf_type.to_owned(),
268
- vec![],
269
- WorkflowOptions::default(),
270
- )
271
- .await
272
- .unwrap();
273
- worker.run_until_done().await.unwrap();
274
- }
275
-
276
- /// Repros a situation where if, upon completing a task there is some internal error which causes
277
- /// us to want to auto-fail the workflow task while there is also an outstanding eviction, the wf
278
- /// would get evicted but then try to send some info down the completion channel afterward, causing
279
- /// a panic.
280
- #[tokio::test]
281
- async fn repro_channel_missing_because_nondeterminism() {
282
- for _ in 1..50 {
283
- let wf_id = "fakeid";
284
- let wf_type = DEFAULT_WORKFLOW_TYPE;
285
- let mut t = TestHistoryBuilder::default();
286
- t.add_by_type(EventType::WorkflowExecutionStarted);
287
- t.add_full_wf_task();
288
- t.add_has_change_marker("patch-1", false);
289
- let _ts = t.add_by_type(EventType::TimerStarted);
290
- t.add_workflow_task_scheduled_and_started();
291
-
292
- let mock = mock_worker_client();
293
- let mut mh =
294
- MockPollCfg::from_resp_batches(wf_id, t, [1.into(), ResponseType::AllHistory], mock);
295
- mh.num_expected_fails = 1;
296
- let mut worker = mock_sdk_cfg(mh, |cfg| {
297
- cfg.max_cached_workflows = 2;
298
- cfg.ignore_evicts_on_shutdown = false;
299
- });
300
-
301
- worker.register_wf(wf_type.to_owned(), move |ctx: WfContext| async move {
302
- ctx.patched("wrongid");
303
- ctx.timer(Duration::from_secs(1)).await;
304
- Ok(().into())
305
- });
306
-
307
- worker
308
- .submit_wf(
309
- wf_id.to_owned(),
310
- wf_type.to_owned(),
311
- vec![],
312
- WorkflowOptions::default(),
313
- )
314
- .await
315
- .unwrap();
316
- worker.run_until_done().await.unwrap();
317
- }
318
- }