[4.x] Attempt to fix model hydration #1174
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt to fix #1081 & #1068.
#1000 introduced the ability to record how many hydrations of a specific model occurred. This however, does not seem to function properly on Vapor specifically. It was originally also post-reported on the related PR but given the nature of it being Vapor specific it was very hard to reproduce for the OP.
My analysis leads me to believe that the saving of the incoming entry occurs and then afterwards, for some reason unknown, Telescope still attempts to hydrate a model when being run on Vapor. Because the incoming entry's
content
has already been json encoded here, it's now a string and the following exception occurs for people:I think this is because of some processing that happens after recording the entry which hydrates the same model again. It seems Vapor specific but most likely it's specifically due to any way an app handles processing after Telescope recording. However I could not in any way reproduce this locally.
Therefor I'm not 100% sure this fix will provide a solution to the aforementioned issues. Someone managed to solve it by modifying the
DatabaseEntriesRepository
but I don't think that's the correct place since this is specific to theModelWatcher
. I do not entirely know if Telescope will attempt to save the new entries again or if it'll ignore it.I'd appreciate it if anyone from the related issues could attempt to deploy a fork of Telescope with this to see if that solves the issue for them on Vapor.