Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Conversation

@NathanFlurry
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Oct 19, 2025

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

Project Deployment Preview Comments Updated (UTC)
rivetkit-next-js-max Ready Ready Preview Comment Oct 19, 2025 9:23pm
rivetkit-serverless Ready Ready Preview Comment Oct 19, 2025 9:23pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

Copy link
Member Author

NathanFlurry commented Oct 19, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link

claude bot commented Oct 19, 2025

Code Review

Summary

This PR adds webpackIgnore magic comments to dynamic imports of optional peer dependencies (eventsource and ws) to prevent webpack from attempting to bundle them during Next.js builds. It also cleans up commented-out dead code.

Positive Aspects

  1. Correct Solution: Using webpackIgnore is the appropriate way to tell webpack to skip bundling optional dependencies that should only be resolved at runtime in Node.js environments.

  2. Code Cleanup: Removes 43 lines of commented-out dead code from eventsource.ts, improving code maintainability.

  3. Improved Documentation: The comment explaining why the custom eventsource library is needed is now properly formatted and more clear.

  4. Consistent Pattern: The same fix is applied to both eventsource.ts and websocket.ts, maintaining consistency across similar code paths.

  5. Indirect Import: Using an intermediate moduleName variable is a good practice to ensure webpack does not try to statically analyze the import string.

Observations and Suggestions

1. Browser EventSource Check Removed

The eventsource.ts file no longer checks for native browser EventSource (typeof EventSource !== undefined), unlike websocket.ts which still has this check at lines 16-18.

Question: Was this intentional? The comment on line 11 states "We can't use the browser-provided EventSource since it does not allow providing custom headers", which suggests this is deliberate. However:

  • Is this because RivetKit always requires custom headers for EventSource connections?
  • Should there be a runtime check that throws a more helpful error in browser environments where the npm package will not be available?

2. Error Handling Consistency

Both files handle missing dependencies gracefully by providing mock classes with clear error messages. This is excellent defensive programming.

3. Testing Considerations

Since these are optional peer dependencies with fallback behavior:

  • Consider adding integration tests that verify the webpack bundling works correctly in Next.js environments
  • Consider tests that validate the mock classes throw appropriate errors when dependencies are missing

Potential Issues

None identified. The changes are minimal, focused, and solve the stated problem without introducing risk.

Performance Considerations

No performance impact. The webpackIgnore comment only affects build-time bundling, not runtime performance.

Security Considerations

No security concerns. The changes do not modify any security-sensitive logic.

Test Coverage

The changes do not require new tests, but as mentioned above, integration tests for webpack bundling behavior could be valuable to prevent regressions.

Code Quality Score: 9/10

Recommendation: Approve

This is a well-executed fix for a specific bundler compatibility issue. The only minor suggestion is to document whether the removal of the browser EventSource check is intentional and if there are any implications for browser-based usage.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 19, 2025

More templates

@rivetkit/actor

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/actor@1408

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/cloudflare-workers@1408

@rivetkit/core

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/core@1408

@rivetkit/db

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/db@1408

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/framework-base@1408

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/next-js@1408

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/react@1408

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivetkit@1408

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/sql-loader@1408

commit: 9d4fdc2

@graphite-app
Copy link

graphite-app bot commented Oct 19, 2025

Merge activity

  • Oct 19, 11:36 PM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Oct 19, 11:36 PM UTC: CI is running for this pull request on a draft pull request (#1410) due to your merge queue CI optimization settings.
  • Oct 19, 11:37 PM UTC: Merged by the Graphite merge queue via draft PR: #1410.

@graphite-app graphite-app bot closed this Oct 19, 2025
@graphite-app graphite-app bot deleted the 10-19-fix_next-js_add_webpackignore_for_optional_dependencies branch October 19, 2025 23:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants