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(web): prevent writing large auspice json to local storage #1471

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

ivan-aksamentov
Copy link
Member

@ivan-aksamentov ivan-aksamentov commented Jun 4, 2024

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:

?dataset-json-url=https://nextstrain.org/ncov/gisaid/global/all-time

After `dataset-json-url` param is used, the entire auspice json was stored in local storage. For large files this would be bigger that 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. 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 this auspice dataset feature releasable.

Can be tested with a large tree like this:

```
?dataset-json-url=https://nextstrain.org/ncov/gisaid/global/all-time
```
Copy link

vercel bot commented Jun 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nextclade 🛑 Canceled (Inspect) Jun 4, 2024 0:50am

@ivan-aksamentov ivan-aksamentov merged commit 8d2cab6 into master Jun 4, 2024
20 checks passed
@ivan-aksamentov ivan-aksamentov deleted the fix/large-auspice-json-local-storage branch June 4, 2024 03:09
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