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: check if property exists on object without executing #1560

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hendrik-depauw-lemon
Copy link
Contributor

Description

When populating the getters on a ReadModel, the getters are executed twice. Once where you would expect it, and once in an if statement to check if the property exists on the ReadModel. In this if statement, there is no check to see if the getter is a promise or not, so it is never awaited. When the getter-promise would eventually return an error, the whole Booster application crashes.

This PR thus fixes two things:

  • Stops unnecessarily executing all getters on ReadModels twice
  • Prevents the app from crashing when an async getter throws an error

Changes

Replaced source[key] !== undefined with key in source.

Checks

  • Project Builds
  • Project passes tests and checks
  • Updated documentation accordingly

Copy link

what-the-diff bot commented Dec 17, 2024

PR Summary

  • Bug Fix Documentation
    A new JSON file was added to accurately document a bug fix in one of our key software packages, @boostercloud/framework-core. The bug previously caused our application to abruptly stop working if there was an error in an asynchronous data-fetching operation on a ReadModel, a component that provides read access to the application's stored data.

  • Code Improvement
    The instances.ts file was updated to enhance the way we check for the existence of properties in the source object in the processProperties function. This contributes to better data handling within our application.

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

Successfully merging this pull request may close these issues.

1 participant