fix(web): prevent writing large auspice json to local storage #1471
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.
When
dataset-json-url
param is used, the entire auspice json was stored in local storage. For large files this might be bigger than what browsers allow and the store operation would fail. Subsequent reads would retrieve either nothing or some fragment of data.Here I add some logic to make sure we store auspice json in memory only. Sadly, this means that page reload wipes all the data and we currently don't have a good mechanism to store the previous dataset URL in order to re-fetch it. This will need to be implemented. Currently I opted for discarding the stored dataset if it was auspice dataset. This should be alright, as the feature was primarily designed to be used when navigating to Nextclade with url params set.
This PR only implements a workaround for something that's fundamentally poorly designed and broken. The full dataset description object is still saved to local storage (just not the full auspice json anymore). The definitive fix requires serious restructuring and altering many components. It will be implemented later (#1464)
But this workaround should allow most use-cases of
dataset-json-url
to work and makes the auspice dataset feature releasable.Can be tested with a large tree like this: