Skip to content

DR-8150: Add Postgres Pub/Sub blog#7863

Merged
ankur-arch merged 4 commits intomainfrom
DR-8150
May 4, 2026
Merged

DR-8150: Add Postgres Pub/Sub blog#7863
ankur-arch merged 4 commits intomainfrom
DR-8150

Conversation

@ankur-arch
Copy link
Copy Markdown
Contributor

@ankur-arch ankur-arch commented May 4, 2026

Summary

  • Add new blog post: TypeScript Migrations in Prisma Next (apps/blog/content/blog/typescript-migrations-in-prisma-next/)
  • Add new blog post: You Don't Need Redis, Postgres Already Has Pub/Sub (apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/), sourced from the Notion draft
  • Includes hero images for both posts

Test plan

  • Run pnpm dev and confirm both posts render at /blog/typescript-migrations-in-prisma-next and /blog/you-dont-need-redis-postgres-already-has-pub-sub
  • Verify hero images load on each post and on the blog index card
  • Check OG/meta tags (metaTitle, metaDescription, metaImagePath) populate correctly
  • Validate code blocks (TypeScript, SQL, JSON, bash, text) syntax-highlight as expected
  • Confirm internal/external links resolve (e.g. create-db docs link, prisma-next GitHub examples)
  • pnpm check and pnpm types:check pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive blog post explaining how to implement Pub/Sub functionality using PostgreSQL's LISTEN/NOTIFY features, including practical code examples demonstrating subscriber and publisher workflows.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment May 4, 2026 10:41am
docs Ready Ready Preview, Comment May 4, 2026 10:41am
eclipse Ready Ready Preview, Comment May 4, 2026 10:41am
site Ready Ready Preview, Comment May 4, 2026 10:41am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Walkthrough

This PR adds a new blog post documenting PostgreSQL's built-in LISTEN/NOTIFY feature as a lightweight Pub/Sub mechanism, complete with a runnable Bun + pg demonstration that shows subscriber and publisher patterns with JSON event payloads.

Changes

PostgreSQL Pub/Sub Blog Post

Layer / File(s) Summary
Frontmatter & Introduction
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx (lines 1–45)
Post metadata and introduction establish the premise that PostgreSQL LISTEN/NOTIFY can replace external Pub/Sub brokers for lightweight workflows.
Concept & Semantics
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx (lines 46–97)
Explanation of Pub/Sub fundamentals and PostgreSQL LISTEN/NOTIFY delivery semantics; toolchain introduction (Bun, pg, Prisma create-db).
Demo Implementation
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx (lines 96–212)
Complete Bun project setup and working code example showing subscriber setup with LISTEN and notification handler, publisher connection, pg_notify usage, orchestration, and error handling.
Execution Guide & Detailed Walkthrough
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx (lines 214–389)
Run instructions, expected console output, and line-by-line code explanation covering database creation, SSL configuration, listener setup, publisher flow, event payload structure, and guidance on durability vs. real-time trade-offs.
Recap
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx (lines 390–400)
Summary of core LISTEN/NOTIFY behavior and acknowledgment of durability limitations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'DR-8150: Add Postgres Pub/Sub blog' clearly summarizes the main change—adding a new blog post about PostgreSQL's Pub/Sub capabilities—and matches the primary objective demonstrated in the raw_summary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


Review rate limit: 3/5 reviews remaining, refill in 21 minutes and 50 seconds.

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

@ankur-arch ankur-arch changed the title DR-8150: Add Prisma Next TypeScript migrations and Postgres Pub/Sub blogs DR-8150: Add Postgres Pub/Sub blog May 4, 2026
@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented May 4, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - May 4, 2026, 10:47 AM

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 (2)
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx (2)

154-158: ⚡ Quick win

Handle non-JSON payloads defensively in the notification handler.

Direct JSON.parse(...) can throw if a listener receives plain-text payloads on the same channel. Add a safe parse fallback to keep the demo resilient.

🛡️ Suggested edit
 subscriber.on("notification", (message) => {
   console.log("\nEvent received");
   console.log("Channel:", message.channel);
-  console.log("Payload:", JSON.parse(message.payload ?? "{}"));
+  const rawPayload = message.payload ?? "{}";
+  let parsedPayload: unknown = rawPayload;
+  try {
+    parsedPayload = JSON.parse(rawPayload);
+  } catch {
+    // keep raw payload when message is not JSON
+  }
+  console.log("Payload:", parsedPayload);
 });

Also applies to: 295-299

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx`
around lines 154 - 158, The notification handler currently calls
JSON.parse(message.payload ?? "{}") which can throw on non-JSON payloads; wrap
the parse in a defensive try/catch (or use a small safeParse helper that returns
the raw string on failure) inside the subscriber.on("notification", (message) =>
{ ... }) callback so the handler logs a fallback value instead of crashing, and
apply the same change to the other subscriber.on("notification", ...) occurrence
in the file.

131-133: Consider pinning create-db version for explicit reproducibility, but note that Prisma's official documentation uses @latest.

While version pinning generally improves reproducibility when CLI output or behavior changes across releases, Prisma's own "Getting started with npx create-db" tutorial explicitly uses @latest and doesn't recommend pinning for this tool. If you want stricter control, pinning to a tested version (currently 1.2.1) is a valid practice; otherwise, @latest aligns with Prisma's documented guidance.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx`
around lines 131 - 133, Replace the dynamic `@latest` specifier in the command
invocation so the script is reproducible: update the `const output = await
$`bunx create-db@latest --region eu-central-1 --json`` line to pin a tested
release (e.g., `create-db@1.2.1`) by changing `@latest` to `@1.2.1` in that
command string.
🤖 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/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx`:
- Around line 154-158: The notification handler currently calls
JSON.parse(message.payload ?? "{}") which can throw on non-JSON payloads; wrap
the parse in a defensive try/catch (or use a small safeParse helper that returns
the raw string on failure) inside the subscriber.on("notification", (message) =>
{ ... }) callback so the handler logs a fallback value instead of crashing, and
apply the same change to the other subscriber.on("notification", ...) occurrence
in the file.
- Around line 131-133: Replace the dynamic `@latest` specifier in the command
invocation so the script is reproducible: update the `const output = await
$`bunx create-db@latest --region eu-central-1 --json`` line to pin a tested
release (e.g., `create-db@1.2.1`) by changing `@latest` to `@1.2.1` in that
command string.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 367addc5-d5c0-4631-aac6-47d65743007d

📥 Commits

Reviewing files that changed from the base of the PR and between 7362058 and 61e8215.

⛔ Files ignored due to path filters (1)
  • apps/blog/public/you-dont-need-redis-postgres-already-has-pub-sub/imgs/you-dont-need-redis-postgres-already-has-pub-sub.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx

@ankur-arch ankur-arch merged commit 45b4fd8 into main May 4, 2026
17 of 18 checks passed
@ankur-arch ankur-arch deleted the DR-8150 branch May 4, 2026 14:24
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.

2 participants