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

Fix memleak caused by directory names containing '.md' or '.mdx' #5264

Merged
merged 1 commit into from
Nov 2, 2022
Merged

Fix memleak caused by directory names containing '.md' or '.mdx' #5264

merged 1 commit into from
Nov 2, 2022

Conversation

VladCuciureanu
Copy link
Contributor

Changes

I must mention, I'm very excited to contribute in some way to this awesome project.
Now, the matter at hand:

This fixes a bug caused by wrongly treating files as markdown. If the project's path contains '.md' (or any markdown extension) serving any page containing javascript results in the server crashing due to the heap running out of memory.

I noticed this behaviour when developing my personal website, 'vladinski.md' :)

Testing

Ran entire test suite.
Writing a test seemed overkill, considering such a peculiar type of bug.
If a test is required, please tell me so and I'll find a way to implement it.

Docs

No docs added since this is a fix that doesn't modify a user's usage.

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2022

🦋 Changeset detected

Latest commit: 9fe2887

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Oct 31, 2022
@VladCuciureanu VladCuciureanu changed the title Fix memleak caused by project dir names containing '.md' Fix memleak caused by directory names containing '.md' Oct 31, 2022
@jasikpark
Copy link
Contributor

mind adding a test fixture for this?

@@ -193,7 +193,7 @@ export default function jsx({ settings, logging }: AstroPluginJSXOptions): Plugi

const { mode } = viteConfig;
// Shortcut: only use Astro renderer for MD and MDX files
if (id.includes('.mdx') || isMarkdownFile(id, { criteria: 'includes' })) {
if (id.includes('.mdx') || isMarkdownFile(id, { criteria: 'endsWith' })) {
Copy link
Member

@MoustaphaDev MoustaphaDev Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this causes memory leaks for markdown files, maybe it does happen for folders with .mdx too? Would you check that please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point. Gonna fix.

@VladCuciureanu
Copy link
Contributor Author

VladCuciureanu commented Oct 31, 2022

mind adding a test fixture for this?

Will do

@VladCuciureanu VladCuciureanu changed the title Fix memleak caused by directory names containing '.md' Fix memleak caused by directory names containing '.md' or '.mdx' Nov 1, 2022
@VladCuciureanu
Copy link
Contributor Author

Added test/fixture for this and also fixed what @MoustaphaDev pointed out.

packages/astro/src/vite-plugin-jsx/index.ts Outdated Show resolved Hide resolved
packages/astro/src/vite-plugin-jsx/index.ts Outdated Show resolved Hide resolved
.changeset/clever-files-wash.md Outdated Show resolved Hide resolved
@bluwy bluwy merged commit 0d27c4a into withastro:main Nov 2, 2022
@bluwy
Copy link
Member

bluwy commented Nov 2, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants