Skip to content

Commit ed97891

Browse files
turekiwardpeet
authored andcommitted
fix(gatsby-plugin-mdx): prevent crash when Markdown syntax error(#17135)
1 parent 295c39b commit ed97891

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/gatsby-plugin-mdx/loaders/mdx-loader.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,16 @@ module.exports = async function(content) {
113113

114114
const source = fileNode && fileNode.sourceInstanceName
115115

116-
const mdxNode = await createMDXNode({
117-
id: `fakeNodeIdMDXFileABugIfYouSeeThis`,
118-
node: fileNode,
119-
content,
120-
})
116+
let mdxNode
117+
try {
118+
mdxNode = await createMDXNode({
119+
id: `fakeNodeIdMDXFileABugIfYouSeeThis`,
120+
node: fileNode,
121+
content,
122+
})
123+
} catch (e) {
124+
return callback(e)
125+
}
121126

122127
// get the default layout for the file source group, or if it doesn't
123128
// exist, the overall default layout

0 commit comments

Comments
 (0)