feat/changelog-display-navigation#2814
Merged
ComputelessComputer merged 9 commits intomainfrom Jan 5, 2026
Merged
Conversation
✅ Deploy Preview for hyprnote-storybook canceled.
|
✅ Deploy Preview for hyprnote canceled.
|
✅ Deploy Preview for howto-fix-macos-audio-selection canceled.
|
Comment on lines
+120
to
+135
| useEffect(() => { | ||
| const key = Object.keys(changelogFiles).find((k) => | ||
| k.endsWith(`/${version}.mdx`), | ||
| ); | ||
|
|
||
| if (!key) { | ||
| setLoading(false); | ||
| return; | ||
| } | ||
|
|
||
| changelogFiles[key]().then((raw) => { | ||
| const markdown = stripImageLine(stripFrontmatter(raw as string)); | ||
| setContent(md2json(markdown)); | ||
| setLoading(false); | ||
| }); | ||
| }, [version]); |
Contributor
There was a problem hiding this comment.
Memory leak and race condition: The async operation in useEffect has no cleanup logic. If the component unmounts before the promise resolves, setContent and setLoading will be called on an unmounted component, causing React warnings and potential memory leaks. Additionally, if version changes rapidly, multiple promises can be in-flight and the last one to resolve wins, not necessarily matching the current version.
useEffect(() => {
let cancelled = false;
const key = Object.keys(changelogFiles).find((k) =>
k.endsWith(`/${version}.mdx`),
);
if (!key) {
setLoading(false);
return;
}
changelogFiles[key]().then((raw) => {
if (cancelled) return;
const markdown = stripImageLine(stripFrontmatter(raw as string));
setContent(md2json(markdown));
setLoading(false);
});
return () => {
cancelled = true;
};
}, [version]);
Suggested change
| useEffect(() => { | |
| const key = Object.keys(changelogFiles).find((k) => | |
| k.endsWith(`/${version}.mdx`), | |
| ); | |
| if (!key) { | |
| setLoading(false); | |
| return; | |
| } | |
| changelogFiles[key]().then((raw) => { | |
| const markdown = stripImageLine(stripFrontmatter(raw as string)); | |
| setContent(md2json(markdown)); | |
| setLoading(false); | |
| }); | |
| }, [version]); | |
| useEffect(() => { | |
| let cancelled = false; | |
| const key = Object.keys(changelogFiles).find((k) => | |
| k.endsWith(`/${version}.mdx`), | |
| ); | |
| if (!key) { | |
| setLoading(false); | |
| return; | |
| } | |
| changelogFiles[key]().then((raw) => { | |
| if (cancelled) return; | |
| const markdown = stripImageLine(stripFrontmatter(raw as string)); | |
| setContent(md2json(markdown)); | |
| setLoading(false); | |
| }); | |
| return () => { | |
| cancelled = true; | |
| }; | |
| }, [version]); | |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
43ea3d4 to
3a6f591
Compare
feb3c8d to
f49876f
Compare
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
f49876f to
831d0d5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description