Closed samouss closed 4 years ago
~in case this is related to #60, then just FYI that I didn't have partial updates enabled when I experienced the particular error mentioned.~
update: just saw your comment https://github.com/algolia/gatsby-plugin-algolia/pull/60#issuecomment-621912826 👍
in case this is related to #60, then just FYI that I didn't have partial updates enabled
It was not the first intent for fix this issue, but yes it does (I've updated the description). I can't really fix one without the other. I've tried but it was not so simpler, so I fixed both.
Closes #52 (I hope)
This PR aims to fix an issue with the option
partialUpdates
enabled. Today, when the index doesn't exist the plugin, throws an error: "Index test_does_not_exist does not exist" because we can't browse on an index that doesn't exist.One possible solution is to force the creation of the index. We avoid more branches in the code and we follow the same logic when the index exists or doesn't exist. To force the creation of the index we use an empty
setSettings + waitTask
to ensure the index is created when we exit the function i.e. safe to browse. The index doesn't exist so the emptysetSettings
call shouldn't remove settings but create the index.This change also fixes the issue described in https://github.com/algolia/gatsby-plugin-algolia/pull/60#issuecomment-621912826 because now we fall-back to
index
when:partialUpdates
is disabled and the index doesn't exist,partialUpdates
is enabled and the index exists.Here is what happens without the fix with
partialUpdates
enabled without the index:With the fix the build completes:
Here is what happens without the fix with
partialUpdates
disabled without the index:With the fix the build completes:
cc @Haroenv