Skip to content

Commit 5651b50

Browse files
avoid createReadStream at runtime
1 parent 702a884 commit 5651b50

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

apps/site/next-data/generators/blogData.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ const generateBlogData = async () => {
6868
const rawFrontmatter = [];
6969

7070
filenames.forEach(filename => {
71+
if (globalThis.navigator?.userAgent === 'Cloudflare-Workers') {
72+
// createReadStream doesn't work in the workers runtime so let's skip this for now
73+
// (note: the logic here does work at build time though)
74+
75+
console.log(`\x1b[31mRUNNING generateBlogData inside workerd, we should avoid this if possible!\x1b[0m`);
76+
77+
resolve({ categories: [], posts: [] });
78+
return;
79+
}
80+
7181
// We create a stream for reading a file instead of reading the files
7282
const _stream = createReadStream(join(blogPath, filename));
7383

0 commit comments

Comments
 (0)