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

double subscribing on certain hasura queries #1464

Open
sqlAlchemyNoob2004 opened this issue Sep 16, 2024 · 3 comments
Open

double subscribing on certain hasura queries #1464

sqlAlchemyNoob2004 opened this issue Sep 16, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@sqlAlchemyNoob2004
Copy link

Checked for duplicates

Yes - I've already checked

Is this a regression?

No - This is a new bug

Version

2.11.12

Describe the bug

It appears that we are issuing the same hasura subscriptions multiple times on certain endpoints.

Inspecting websocket traffic for subscription SubActivityDirectives I can see that on page load we are sending the same subscribe message twice:

Screenshot 2024-09-16 at 4 01 11 PM
Screenshot 2024-09-16 at 4 01 24 PM

Unless I'm missing something, these are two unique subscriptions to the same query with the same planId variable.

I can see future updates over the socket come in twice:

Screenshot 2024-09-16 at 4 02 23 PM
Screenshot 2024-09-16 at 4 02 35 PM

Looking at effects.ts it appears we import activityDirectivesDB which is one subscription but we also create another when we call getActivitiesForPlan (

const query = convertToQuery(gql.SUB_ACTIVITY_DIRECTIVES);
const data = await reqHasura<ActivityDirectiveDB[]>(query, { planId }, user);
).

Does this create a second? Should getActivitiesForPlan just use the activityDirectivesDB which has already been initialized?

I'm not super familiar with aerie so maybe this is by design, but it seems kinda wasteful. Could also be causing unneeded re-renders on data that hasn't actually changed.

Reproduction

just inspect traffic in devtools

Logs

No response

System Info

chrome

Severity

Minor

@sqlAlchemyNoob2004 sqlAlchemyNoob2004 added the bug Something isn't working label Sep 16, 2024
@duranb
Copy link
Collaborator

duranb commented Sep 16, 2024

@sqlAlchemyNoob2004 Yeah, getActivitiesForPlan is more for getting the activities for the plan more immediately for processing plan export, whereas the subscription is to handle updates after loading the plan view. They definitely use the same query except one should just be a fetch vs a websocket. This is still good to look more in to in general though. Thank you!

@sqlAlchemyNoob2004
Copy link
Author

@duranb wanted to update this and say this issue isn't limited to subscriptions

i'm seeing this for regular queries as well, most egregiously on the parsed dictionaries. the response of these queries can be pretty big, so it would be good to not double request them if not needed:

Screenshot 2024-09-19 at 11 42 58 AM
Screenshot 2024-09-19 at 11 43 10 AM

@duranb
Copy link
Collaborator

duranb commented Sep 19, 2024

@sqlAlchemyNoob2004 nice find! My suspicion is it has something to do with https://github.com/NASA-AMMOS/aerie-ui/blob/develop/src/components/sequencing/SequenceEditor.svelte#L126. Might need to make more granular reactive statements to not capture unnecessary updates to svelte states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants