DR-8150: Add Postgres Pub/Sub blog#7863
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR adds a new blog post documenting PostgreSQL's built-in ChangesPostgreSQL Pub/Sub Blog Post
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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 |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx (2)
154-158: ⚡ Quick winHandle 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 pinningcreate-dbversion 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
@latestand 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,@latestaligns 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
⛔ 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.pngis excluded by!**/*.png
📒 Files selected for processing (1)
apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/index.mdx
Summary
apps/blog/content/blog/typescript-migrations-in-prisma-next/)apps/blog/content/blog/you-dont-need-redis-postgres-already-has-pub-sub/), sourced from the Notion draftTest plan
pnpm devand confirm both posts render at/blog/typescript-migrations-in-prisma-nextand/blog/you-dont-need-redis-postgres-already-has-pub-submetaTitle,metaDescription,metaImagePath) populate correctlycreate-dbdocs link, prisma-next GitHub examples)pnpm checkandpnpm types:checkpass🤖 Generated with Claude Code
Summary by CodeRabbit
LISTEN/NOTIFYfeatures, including practical code examples demonstrating subscriber and publisher workflows.