Skip to content
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

fix(agama): serialization of undesired content when a flow crashes #6530

Closed
jgomer2001 opened this issue Nov 9, 2023 · 1 comment · Fixed by #6609 or #6614
Closed

fix(agama): serialization of undesired content when a flow crashes #6530

jgomer2001 opened this issue Nov 9, 2023 · 1 comment · Fixed by #6609 or #6614
Assignees
Labels
comp-agama Touching folder /agama kind-bug Issue or PR is a bug in existing functionality
Milestone

Comments

@jgomer2001
Copy link
Contributor

When a flow A calls another B, if B crashes and A catches the crash, an undesired behavior occurs when hitting RRF (at A): all variables of B including the expection that caused the crashed are being serialized

Example for more clarity:

Flow A
    ...
foo ="bar"
result | E = Trigger B
...
E = null
RRF "blah.ftl"
...
Finish ...



Flow B
    ...
foo2 = "bar2"
Call something.that#crashes // --> Java exception occurring here
...

In this case, variable foo2 plus the exception is serialized when the RRF at A is executed. This makes no sense because flow B is already "gone" by then. Surprisingly, even if the caught exception is nulled (E in the example), it tries to serialize it

It is uncertain why Rhino is doing this

@jgomer2001 jgomer2001 self-assigned this Nov 9, 2023
@mo-auto mo-auto added comp-agama Touching folder /agama kind-bug Issue or PR is a bug in existing functionality labels Nov 9, 2023
@jgomer2001
Copy link
Contributor Author

jgomer2001 commented Nov 10, 2023

After many rounds of playing with transpiled code I discovered the situation is presented whenever a (flow) function terminates execution abruptly, be it caused by a Java Call that threw exception or by any other error, e.g. accessing a member of an inexisting variable

Even Java Calls that have exception handling (like var | E = Call ...) provoke the undesired serialization when the exception is caught!

Serialization of arbitrary variables is already problematic. It is necessary to avoid serialization of unnecessary variables at all cost. A solution has to address the following:

  • Ensure Calls are always "successful". This can be done by wrapping the original Java invocation with a Java try-catch and returning a pair with the result of the invocation plus the exception, if any. This way, Java exceptions are not handled at Javascript level
  • Ensure functions do not throw. This can be done with a big try/catch block for every function and returning the (Javascript) error, if any, from the catch block

With the two points above, functions will always return a definite value. To implement the solution (ie. no throws) a transpiler rework is required

jgomer2001 added a commit that referenced this issue Nov 22, 2023
yuriyz pushed a commit that referenced this issue Nov 22, 2023
* chore: update engine to conform transpiler changes #6530

* feat: rework transpiler as per #6530
@jgomer2001 jgomer2001 reopened this Nov 22, 2023
@moabu moabu added this to the 1.0.21 milestone Nov 30, 2023
devrimyatar pushed a commit that referenced this issue Dec 30, 2023
* chore: update engine to conform transpiler changes #6530

* feat: rework transpiler as per #6530

Signed-off-by: Mustafa Baser <mbaser@mail.com>
devrimyatar pushed a commit that referenced this issue Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-agama Touching folder /agama kind-bug Issue or PR is a bug in existing functionality
Projects
None yet
3 participants