Skip to content

Finally hook errors? #38

Closed
Closed

Description

@justinabrahms

What happens when a finally hook errors?

Here's some example evaluation logic:

try {
  run_before_hooks()
  get_value()
  run_after_hooks()
} catch() {
  run_error_hooks()
} finally {
  run_finally_hooks()
}

If the finally hooks throw errors, they won't be caught which breaks 1.19 from the spec.

Otherwise, our code looks like this (which is very janky).

try {
  try {
    run_before_hooks()
    get_value()
    run_after_hooks()
  } catch() {
    run_error_hooks()
  } finally {
    run_finally_hooks()
  }
} finally {
  run_error_hooks() # again?
}

Activity

  1. toddbaert commented on Apr 25, 2022

    @toddbaert
    Member

    I think catch should have run_error_hooks() as well, (maybe I'm confused). We also mentioned that throwing in an error hook would also be bubble up that error, which would be another exception to 1.19 we should probably note in the spec.

    I feel less sure about what the behavior should be in finally hooks. I think I could go either way on it, but it should certainly be documented. I suppose you could think of it like try/catch/finally in most languages, which will bubble up an exception if you throw in finally... so that might be a reasonable choice for us.

    See https://github.com/open-feature/sdk-research/blob/main/packages/openfeature-extra/src/lib/hooks/open-telemetry-hook.ts for a real life example of all the hook life-cycle events.

  2. added
    architecture
    on Apr 25, 2022
  3. justinabrahms commented on May 27, 2022

    @justinabrahms
    MemberAuthor

    Updated the error_handling to run_error_hooks, which should make it clearer.

  4. toddbaert commented on May 27, 2022

    @toddbaert
    Member

    We might want to close this for now. Both the Java and Node SDKs throw errors from finally and error hooks it seems... which IMHO is fine. Hooks are "user defined" code, and I think throwing it them is reasonable in certain cases, particularly finally and error. Especially in the case of errors, it actually provides a mechanism to force errors to bubble up for debugging purposes, which seems like it could be useful in dev environments.

  5. justinabrahms commented on May 27, 2022

    @justinabrahms
    MemberAuthor
  6. toddbaert commented on May 27, 2022

    @toddbaert
    Member

    It seems to me this is partially already in the spec (4.3): https://github.com/open-feature/spec/blob/main/specification/flag-evaluation/hooks.md#requirement-43

    But we should also say something similar about error I guess?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecture

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions