Skip to content

Commit

Permalink
Fix mutation chunking PR (#618)
Browse files Browse the repository at this point in the history
* mutation chunks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* exclude helm charts from prettier

* adjust prettier exclusion

* fixup changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update

* add todo

* increase chunk size further

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
theosanderson and pre-commit-ci[bot] authored Oct 8, 2024
1 parent 8250a2b commit faa18f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

helm_charts/**
4 changes: 2 additions & 2 deletions taxonium_backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ app.get("/mutations/", function (req, res) {
res.write(`data: ${data}\n\n`);
}

// Send mutations in chunks of 1000
const chunkSize = 10000;
// Send mutations in chunks of 100000
const chunkSize = 100000;
let index = 0;

function sendNextChunk() {
Expand Down
9 changes: 5 additions & 4 deletions taxonium_component/src/hooks/useServerBackend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function useServerBackend(backend_url, sid, url_on_fail) {
const mutationsChunk = JSON.parse(event.data);
if (Array.isArray(mutationsChunk)) {
config.mutations.push(...mutationsChunk);
setResult({ ...config });

console.log(
`Received chunk of ${mutationsChunk.length} mutations`
);
Expand All @@ -172,10 +172,11 @@ function useServerBackend(backend_url, sid, url_on_fail) {
eventSource.onerror = (error) => {
console.error("EventSource failed:", error);
eventSource.close();
setResult(config);
// TODO atm we set the Result above for backwards compatibility with backends which don't stream mutations and use /config/
// instead. After a while we should stop doing this so that if the stream dies in the middle we don't get
// possible weird behavior.
};

// Set initial config
setResult(config);
})
.catch((error) => {
console.error("Error fetching config:", error);
Expand Down

0 comments on commit faa18f2

Please sign in to comment.