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 bug during local running #326

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

seanspeaks
Copy link
Contributor

When running an app locally, the first time an integration record is retrieved by ID and the module-factory is run, the app errors out.

Specifically, getModuleInstanceFromEntityId fails to find the moduleDefinition, only on the first invocation.

After debugging with logs and inspection, it looks like mongoose (current version?) fails to initialize the descriminator decorator on the mongoose object being evaluated (entity['__t'] comes up undefined). Subsequent requests succeed. This makes me believe there's something to do with initializing the mongoDB connection or mongoose collections.

One patch fix here is to force the mongoose object to finish initializing by calling toJSON.

Works locally for me, unclear how to write the test to prove it out.

…dded to the mongoose model (currently undefined on initialization and first invocation)
@seanspeaks seanspeaks added bug Something isn't working patch Increment the patch version when merged release Create a release when this pr is merged labels Aug 8, 2024
Copy link

sonarcloud bot commented Aug 8, 2024

Copy link
Contributor

@d-klotz d-klotz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a task to investigate further, this PR fixes the issue but the root cause is still not clear and can probably happen to other methods in there, right?

@seanspeaks seanspeaks merged commit 6572f99 into main Aug 8, 2024
7 of 8 checks passed
@seanspeaks
Copy link
Contributor Author

🚀 PR was released in v1.2.1 🚀

@seanspeaks seanspeaks added the released This issue/pull request has been released. label Aug 8, 2024
@seanspeaks
Copy link
Contributor Author

We should create a task to investigate further, this PR fixes the issue but the root cause is still not clear and can probably happen to other methods in there, right?

So created 👍 FRI-459

@MichaelRyanWebber
Copy link
Contributor

@seanspeaks and @d-klotz You're definitely on to something there Sean.

This is the same issue that I had to work around in getInstance:

https:/friggframework/frigg/blob/main/packages/core/module-plugin/auther.js#L119

I also remember seeing this behavior before, I had added the error check but hadn't been seeing the error, so hadn't put it together.

Will be great to get to the root cause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch Increment the patch version when merged release Create a release when this pr is merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants