@@ -232,23 +232,16 @@ private <T, E extends Exception> WorkflowHandle<T, E> debounceInternal(
232232
233233 DBOSExecutor .Invocation invocation = executor .captureInvocation (wfLambda );
234234
235- // Inside a workflow, ID generation is wrapped in a step so replay is deterministic.
236- DebounceIds ids ;
237- if (DBOS .inWorkflow () && !DBOS .inStep ()) {
238- ids =
239- executor .runDbosFunctionAsStep (
240- () ->
241- new DebounceIds (
242- DBOSContextHolder .get ().getNextWorkflowId (UUID .randomUUID ().toString ()),
243- UUID .randomUUID ().toString ()),
244- "DBOS.assignDebounceIds" ,
245- null );
246- } else {
247- ids =
248- new DebounceIds (
249- DBOSContextHolder .get ().getNextWorkflowId (UUID .randomUUID ().toString ()),
250- UUID .randomUUID ().toString ());
251- }
235+ // Inside a workflow, ID generation is wrapped in a step so replay is deterministic;
236+ // runDbosFunctionAsStep runs the lambda directly when not in a workflow.
237+ DebounceIds ids =
238+ executor .runDbosFunctionAsStep (
239+ () ->
240+ new DebounceIds (
241+ DBOSContextHolder .get ().getNextWorkflowId (UUID .randomUUID ().toString ()),
242+ UUID .randomUUID ().toString ()),
243+ "DBOS.assignDebounceIds" ,
244+ null );
252245 String userWorkflowId = ids .userWorkflowId ();
253246 String messageId = ids .messageId ();
254247
@@ -292,12 +285,10 @@ private <T, E extends Exception> WorkflowHandle<T, E> debounceInternal(
292285 // replay returns the same debouncer id and the subsequent send/getEvent steps stay
293286 // deterministic. Mirrors Python's call_function_as_step("DBOS.get_deduplicated_workflow").
294287 String existingDebouncerId =
295- (DBOS .inWorkflow () && !DBOS .inStep ())
296- ? executor .runDbosFunctionAsStep (
297- () -> lookupExistingDebouncerId (debouncerDeduplicationId ),
298- "DBOS.lookupDebouncer" ,
299- null )
300- : lookupExistingDebouncerId (debouncerDeduplicationId );
288+ executor .runDbosFunctionAsStep (
289+ () -> lookupExistingDebouncerId (debouncerDeduplicationId ),
290+ "DBOS.lookupDebouncer" ,
291+ null );
301292 if (existingDebouncerId == null ) {
302293 // The existing debouncer finished between the enqueue attempt and now. Retry from
303294 // scratch — the next enqueue should succeed.
0 commit comments