Skip to content

MARISSA MOLEJON | OCT2025-1 | Module-Legacy-Code | Sprint 1 | fix hashtag slowing browser - #4

Open
marissamolejon wants to merge 1 commit into
mainfrom
fix/hashtag-infinite-fetch-loop
Open

MARISSA MOLEJON | OCT2025-1 | Module-Legacy-Code | Sprint 1 | fix hashtag slowing browser#4
marissamolejon wants to merge 1 commit into
mainfrom
fix/hashtag-infinite-fetch-loop

Conversation

@marissamolejon

Copy link
Copy Markdown
Owner

Summary

clicking a hashtag caused the page to flash blank on and
off repeatedly, driven by an infinite loop of network requests.

Fix

Added a guard before the fetch call:

if (state.currentHashtag !== `#${hashtag}`) {
  apiService.getBloomsByHashtag(hashtag);
}

Note on a mismatch worth flagging for reviewers: state.currentHashtag
is stored with a leading # (set inside getBloomsByHashtag in
api.mjs), while the hashtag parameter passed into hashtagView()
from the router never has one. The guard accounts for this by
comparing against `#${hashtag}`, not a plain string match — an
earlier draft of this fix missed that and silently never blocked
anything.

Once a hashtag's data is loaded, the state stays in sync with the
current view and no further fetch (and therefore no further
state-change event) occurs, breaking the loop after exactly one
request.

Testing

Verified via the Network tab:

  • Before fix: navigating to any hashtag produced an unbounded,
    continuously growing number of requests (observed 2900+ and still
    climbing).
  • After fix, #do (a hashtag with no matching blooms): exactly
    one fetch, empty result rendered correctly, no further requests.
  • After fix, #SwizBiz (a hashtag with real data): exactly one
    fetch, both matching blooms rendered correctly, no further
    requests.
  • Confirmed via localStorage inspection that currentHashtag and
    hashtagBlooms reflect the correct, final state in both cases.

Scope

Single file changed: front-end/views/hashtag.mjs. No backend
changes.

@marissamolejon marissamolejon changed the title MARISSA MOLEJON | OCT2025-1 | Module-Legacy-Code | Sprint 1 | fix hashtag slowing my browser MARISSA MOLEJON | OCT2025-1 | Module-Legacy-Code | Sprint 1 | fix hashtag slowing browser Jul 6, 2026
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