Skip to content

ENG-1551 - Fixing "Serverless function has exceeded ..."#927

Merged
mdroidian merged 1 commit intomainfrom
eng-1551-fixing-serverless-function-has-exceeded
Mar 30, 2026
Merged

ENG-1551 - Fixing "Serverless function has exceeded ..."#927
mdroidian merged 1 commit intomainfrom
eng-1551-fixing-serverless-function-has-exceeded

Conversation

@mdroidian
Copy link
Copy Markdown
Member

@mdroidian mdroidian commented Mar 30, 2026

  • Introduced a new blogDirectory.ts file to centralize the blog directory path management.
  • Updated readBlogs.tsx and page.tsx to import and use BLOG_DIRECTORY instead of the previously hardcoded BLOG_PATH.
  • Removed the BLOG_PATH constant from constants.ts to streamline the codebase.

" Root cause was the blog filesystem lookup used by / and /blog. It was resolving the blog directory from process.cwd(), which made Next/Vercel’s file tracer over-approximate the dependency set and pull in most of apps/website/.next including webpack cache packs, plus all of apps/website/public. That matches your Vercel log: .next ~228.5 MB + public ~49 MB, and it also explains why a redeploy sometimes passes, since the .next/cache contents vary between builds."

"...the home/blog traces dropped from roughly 573 MB each to about 1.8 MB, which is exactly the Vercel issue we were trying to eliminate."


Open with Devin

Summary by CodeRabbit

  • Refactor
    • Refactored blog directory path resolution for improved modularity and consistency.

- Introduced a new blogDirectory.ts file to centralize the blog directory path management.
- Updated readBlogs.tsx and page.tsx to import and use BLOG_DIRECTORY instead of the previously hardcoded BLOG_PATH.
- Removed the BLOG_PATH constant from constants.ts to streamline the codebase.
@linear
Copy link
Copy Markdown

linear bot commented Mar 30, 2026

@supabase
Copy link
Copy Markdown

supabase bot commented Mar 30, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@mdroidian
Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

This PR refactors blog directory path resolution by introducing a new module that computes the blog directory path using import.meta.url, replacing the previous approach of using a string constant BLOG_PATH that required runtime path resolution. The new centralized BLOG_DIRECTORY export is then imported across blog-related files.

Changes

Cohort / File(s) Summary
Blog Directory Path Centralization
apps/website/app/(home)/blog/blogDirectory.ts
New module that derives the blog directory path from import.meta.url and exports BLOG_DIRECTORY as the computed path to the posts subdirectory.
Blog Utilities Updated
apps/website/app/(home)/blog/page.tsx, apps/website/app/(home)/blog/readBlogs.tsx
Updated imports to use the new BLOG_DIRECTORY from blogDirectory.ts instead of the BLOG_PATH constant from ~/data/constants. Removed unused path import from page.tsx.
Constants Cleanup
apps/website/app/data/constants.ts
Removed the exported BLOG_PATH constant that is no longer needed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title references a specific issue (ENG-1551) and mentions fixing a serverless function error, but does not clearly convey the actual change: centralizing blog directory path management to resolve the issue. Consider a more specific title like 'Refactor blog directory path to centralize configuration and fix serverless timeout' to better describe the actual implementation.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/website/app/(home)/blog/blogDirectory.ts (1)

1-9: Consider using new URL() pattern for more robust file path resolution.

The current implementation using fileURLToPath(import.meta.url) works correctly in Next.js 15 and Turbopack. However, the more robust pattern for file path resolution is new URL('./relative-path', import.meta.url).pathname, which explicitly constructs a file URL and is more resilient to bundler transformations.

If you prefer stronger type safety and consistency with modern ESM patterns, consider refactoring to:

Suggested refactor
import path from "node:path";

const BLOG_MODULE_PATH = new URL(".", import.meta.url).pathname;

export const BLOG_DIRECTORY = path.join(BLOG_MODULE_PATH, "posts");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/website/app/`(home)/blog/blogDirectory.ts around lines 1 - 9, Replace
the fileURLToPath(import.meta.url) approach with the new URL(...) pattern for
more robust ESM path resolution: update the BLOG_MODULE_PATH initialization to
use new URL(".", import.meta.url).pathname, remove the unused fileURLToPath
import, and keep BLOG_DIRECTORY built via path.join(BLOG_MODULE_PATH, "posts")
so that BLOG_MODULE_PATH and BLOG_DIRECTORY use the new URL-based pathname
resolution.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/website/app/`(home)/blog/blogDirectory.ts:
- Around line 1-9: Replace the fileURLToPath(import.meta.url) approach with the
new URL(...) pattern for more robust ESM path resolution: update the
BLOG_MODULE_PATH initialization to use new URL(".", import.meta.url).pathname,
remove the unused fileURLToPath import, and keep BLOG_DIRECTORY built via
path.join(BLOG_MODULE_PATH, "posts") so that BLOG_MODULE_PATH and BLOG_DIRECTORY
use the new URL-based pathname resolution.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f8071cc0-f673-4e38-9787-62d9f84c136c

📥 Commits

Reviewing files that changed from the base of the PR and between baaa863 and c3c8219.

📒 Files selected for processing (4)
  • apps/website/app/(home)/blog/[slug]/page.tsx
  • apps/website/app/(home)/blog/blogDirectory.ts
  • apps/website/app/(home)/blog/readBlogs.tsx
  • apps/website/app/data/constants.ts
💤 Files with no reviewable changes (1)
  • apps/website/app/data/constants.ts

@mdroidian mdroidian merged commit 69bf42c into main Mar 30, 2026
8 checks passed
@mdroidian mdroidian deleted the eng-1551-fixing-serverless-function-has-exceeded branch March 30, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant