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

Collab summit followups #1

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid createReadStream at runtime
dario-piotrowicz committed Nov 15, 2024
commit 5651b50a42ab848b226f553bdc91c221e893562e
10 changes: 10 additions & 0 deletions apps/site/next-data/generators/blogData.mjs
Original file line number Diff line number Diff line change
@@ -68,6 +68,16 @@ const generateBlogData = async () => {
const rawFrontmatter = [];

filenames.forEach(filename => {
if (globalThis.navigator?.userAgent === 'Cloudflare-Workers') {
// createReadStream doesn't work in the workers runtime so let's skip this for now
// (note: the logic here does work at build time though)

console.log(`\x1b[31mRUNNING generateBlogData inside workerd, we should avoid this if possible!\x1b[0m`);

resolve({ categories: [], posts: [] });
return;
}

// We create a stream for reading a file instead of reading the files
const _stream = createReadStream(join(blogPath, filename));