Skip to content

Unexpected Behavior of bpmn-engine When Using flow-extensions #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kovacsgergelydpr opened this issue Mar 24, 2025 · 2 comments
Closed

Comments

@kovacsgergelydpr
Copy link

Hi there!

I would like to use bpmn-engine together with the @onify/flow-extensions package, but I encountered the following unexpected behavior:
When I register the extensions package in the engine, the await engine.execute() command does not wait synchronously for the UserTask instances to reach the wait status. Instead, it returns immediately after the StartEvent completes.

This makes state persistence problematic because calling execution.getState() still returns the state before reaching wait.

If I don't use the extensions package, everything continues to work as expected, just like in our previous implementations.

Please help me determine whether this is a bug or if I am not using the package correctly.
If this is the expected behavior, could you advise on which event handler I should use to wait for the parallel UserTasks to reach the 'wait' status so I can properly save the state?

I have created a StackBlitz project to make it easy to reproduce the issue:
https://stackblitz.com/edit/stackblitz-starters-3wpwgade?file=index.mjs

Thank you!
Gergely Kovács
DPR Ltd.

@paed01
Copy link
Contributor

paed01 commented Mar 29, 2025

It is not a bug. The behaviour changes since camunda extensions allows for scripts to be executed when resolving input/output. And scripts are executed asynchronously, hence all formatting will be asynchronous regardless if you use script formatting or not.

You can use the listener to decide when to stop and save state.

Have a look at bpmn-middleware example app for inspiration on how to handle state.

@kovacsgergelydpr
Copy link
Author

Thank you for the clarification and for pointing me to the example app!
I really appreciate your help and the guidance on handling state.
I'll review the bpmn-middleware example to better understand the approach.
Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants