Skip to content

fix: avoid queueing up repeated config/schema reloads#8336

Merged
BrynCooke merged 5 commits intodevfrom
renee/reduce-watch-spam
Oct 16, 2025
Merged

fix: avoid queueing up repeated config/schema reloads#8336
BrynCooke merged 5 commits intodevfrom
renee/reduce-watch-spam

Conversation

@goto-bus-stop
Copy link
Member

@goto-bus-stop goto-bus-stop commented Sep 25, 2025

If you have a big complicated supergraph that takes some time to load,
and you edit it multiple times in a short time frame, it causes multiple
notify events to queue up. These are all handled individually, and all
cause a full schema reload.

Let's assume I do this.

  • Start the router. It takes a few seconds to load the initial supergraph
    schema.
  • Now I modify the supergraph schema file. This emits a notify event "A". The router starts loading the supergraph schema.
  • I modify it again. This queues an additional notify event "B". The
    loop inside files.rs starts spinning until event "A" is handled.
  • I modify it again. This queues an additional notify event "C". This
    stays inside the notify crate until event "B" is handled.
  • The router finishes loading the supergraph schema.
  • Event "A" is now finished, so event "B" can be sent on the channel,
    and the router starts loading the supergraph schema again.
  • notify sees that the callback for event "B" has completed so it
    emits event "C".
  • files.rs starts spinning until event "B" is handled.
  • Finally, when the router has loaded the supergraph again, we emit
    event "C" and trigger another reload.

All the while, the user repeatedly sees a "could not process file watch
notification" warning.

For events "B" and "C", the supergraph hasn't actually changed.

This PR silences the log error message and prevents trying to loop repeatedly to add another event to a full queue as byt definition there is an event queued already.



Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

Note any exceptions here
No docs or perf testing needed as this is not a change in functionality and it won't affect perf as it is to do with reload.
Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

If you have a big complicated supergraph that takes some time to load,
and you edit it multiple times in a short time frame, it causes multiple
`notify` events to queue up. These are all handled individually, and all
cause a full schema reload.

Let's assume I do this.

- Start the router. It takes a few seconds to load the initial supergraph
  schema.
- Now I modify the supergraph schema file. This emits a notify event "A". The router starts loading the supergraph schema.
- I modify it again. This queues an additional notify event "B". The
  loop inside files.rs starts spinning until event "A" is handled.
- I modify it again. This queues an additional notify event "C". This
  stays inside the `notify` crate until event "B" is handled.
- The router finishes loading the supergraph schema.
- Event "A" is now finished, so event "B" can be sent on the channel,
  and the router starts loading the supergraph schema again.
- `notify` sees that the callback for event "B" has completed so it
  emits event "C".
- `files.rs` starts spinning until event "B" is handled.
- Finally, when the router has loaded the supergraph again, we emit
  event "C" and trigger another reload.

All the while, the user repeatedly sees a "could not process file watch
notification" warning.

For events "B" and "C", the supergraph hasn't actually changed.
@apollo-librarian
Copy link
Contributor

apollo-librarian bot commented Sep 25, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: b1c3fd6f3871516140b573fc
Build Logs: View logs

@github-actions

This comment has been minimized.

@goto-bus-stop goto-bus-stop marked this pull request as ready for review October 16, 2025 09:56
@goto-bus-stop goto-bus-stop requested a review from a team October 16, 2025 09:56
@goto-bus-stop goto-bus-stop requested a review from a team as a code owner October 16, 2025 09:56
@BrynCooke BrynCooke enabled auto-merge (squash) October 16, 2025 09:59
@BrynCooke BrynCooke merged commit 732854b into dev Oct 16, 2025
15 checks passed
@BrynCooke BrynCooke deleted the renee/reduce-watch-spam branch October 16, 2025 10:20
@abernix abernix mentioned this pull request Oct 27, 2025
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.

2 participants