Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@devkiran
Copy link
Collaborator

@devkiran devkiran commented Dec 19, 2025

Fix waitUntil can only be called with a Promise, got string

Summary by CodeRabbit

  • Refactor
    • Optimized analytics dashboard API response handling for improved performance by adjusting how background data persistence operations are managed.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Contributor

vercel bot commented Dec 19, 2025

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

Project Deployment Review Updated (UTC)
dub Ready Ready Preview Dec 19, 2025 10:52am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

A Redis write operation in the analytics dashboard API route is modified to pass an unawaited promise directly to waitUntil() instead of awaiting before passing it. This affects how the promise settles relative to the response cycle.

Changes

Cohort / File(s) Summary
Redis operation handling
apps/web/app/api/analytics/dashboard/route.ts
Removed await before redis.set() call within waitUntil(), changing promise handling and error propagation semantics

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the change is intentional and understand the semantic difference in how waitUntil() handles an unawaited promise vs. an awaited one
  • Confirm error handling implications: errors in the Redis operation will no longer propagate to the response, but rather be handled asynchronously by the runtime
  • Ensure this aligns with the intended behavior for analytics tracking (fire-and-forget pattern)

Poem

🐰 A promise set free, no await to delay,
Fire-and-forget in the Redis way,
Faster response, let background play! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically describes the main change: fixing the waitUntil call in the analytics dashboard route, which aligns with the summary showing the Redis set call modification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-share-analytics

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0b4fb and 2789bb7.

📒 Files selected for processing (1)
  • apps/web/app/api/analytics/dashboard/route.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-02T22:46:22.739Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2924
File: apps/web/lib/api/conversions/track-lead.ts:7-7
Timestamp: 2025-10-02T22:46:22.739Z
Learning: In apps/web/lib/api/conversions/track-lead.ts, lead events are cached in Redis for 5 minutes (keys: `leadCache:${customer.id}` and `leadCache:${customer.id}:${stringifiedEventName}`) to provide immediate data availability while Tinybird ingestion happens asynchronously. This caching pattern allows for async-only recording without breaking "wait" mode semantics.

Applied to files:

  • apps/web/app/api/analytics/dashboard/route.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
apps/web/app/api/analytics/dashboard/route.ts (1)

166-166: Correct usage of waitUntil() with Redis cache operation.

The waitUntil() method enqueues an asynchronous task to be performed during the lifecycle of the request and doesn't block the response. Passing the promise directly (not awaited) ensures the Redis cache write executes asynchronously in the background while the response returns immediately. If the promise passed to waitUntil fails, the serverless function will still complete and return a response, which is appropriate for non-critical caching operations.


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.

@devkiran devkiran requested a review from steven-tey December 19, 2025 10:47
@devkiran devkiran changed the title Fix waitUntil call in /api/analytics/dashboard Fix waitUntil call in /api/analytics/dashboard Dec 19, 2025
@steven-tey steven-tey merged commit bcbb08c into main Dec 19, 2025
8 of 9 checks passed
@steven-tey steven-tey deleted the fix-share-analytics branch December 19, 2025 16:27
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.

3 participants