Skip to content

Extend on state change with previous state#1179

Closed
joshua1 wants to merge 531 commits intorivet-dev:mainfrom
joshua1:extend-on-state-change-with-previous-state
Closed

Extend on state change with previous state#1179
joshua1 wants to merge 531 commits intorivet-dev:mainfrom
joshua1:extend-on-state-change-with-previous-state

Conversation

@joshua1
Copy link
Copy Markdown

@joshua1 joshua1 commented Aug 25, 2025

modify onStateChange so that previous state is also passed to the lifecycle event call back . This will help with granular broadcast where necessary after comparing new and previous state , as well as other comparisons as needed

connorads and others added 30 commits April 5, 2025 15:12
* Add `get-port` as dev dep

In rivet-dev#790 `get-port` was added to [`packages/actor-core/src/test/mod.ts`](packages/actor-core/src/test/mod.ts)

Get an error when you run the example

```sh
npx create-actor@0.7.9
npm run test
```

```
➜ npm run test

> counter@0.0.0 test
> vitest run


 RUN  v3.1.1 /Users/username/git/actor-core-counter


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  tests/counter.test.ts [ tests/counter.test.ts ]
Error: Cannot find package 'get-port' imported from /Users/username/git/actor-core-counter/node_modules/actor-core/dist/test/mod.js
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


 Test Files  1 failed (1)
      Tests  no tests
   Start at  14:59:12
   Duration  209ms (transform 24ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 35ms)
```

* How embarassing

* Update yarn.lock
NathanFlurry and others added 24 commits July 27, 2025 19:07
Release-As: 0.9.7
Release-As: 0.9.8
Closes KIT-178, KIT-115

### TL;DR

Add Next.js framework support with a working example and update documentation links.

### What changed?

- Added a new `@rivetkit/next-js` package with Next.js integration
- Created a complete Next.js example application in `examples/next-js`
- Updated the GitHub workflow to include templates from examples directory
- Fixed the basePath handling in the core router to support custom API paths
- Updated documentation links throughout the README to point to rivet.gg domain
- Added a pkg.pr.new badge to the README for easy testing

### How to test?

1. Run the Next.js example:
```bash
cd examples/next-js
pnpm install
pnpm dev
```

2. Open http://localhost:3000 to see the counter example
3. Try incrementing the counter and changing the counter name
4. Verify the API routes work correctly at `/api/registry`

### Why make this change?

Next.js is one of the most popular React frameworks, and this integration allows RivetKit to be easily used in Next.js applications. The example demonstrates how to set up actors, create API routes, and use the React hooks in a Next.js environment. This expands RivetKit's framework support and makes it more accessible to developers using Next.js.
…vet-dev#1158)

The JSON encoding path in handleAction was expecting a raw array for action arguments,
while the client was sending {a: [...]} format. This caused "Invalid JSON" errors when
explicitly specifying encoding: "json" in the client.

This fix ensures both JSON and CBOR encodings use the same ActionRequestSchema format
for consistency, matching the client's expected behavior.

🤖 Generated with [opencode](https://opencode.ai)

Co-authored-by: opencode <noreply@opencode.ai>
Release-As: 0.9.9
Closes FRONT-742

### TL;DR

Added connection liveness checking to detect and clean up stale WebSocket connections.

### What changed?

- Implemented a connection liveness system that periodically checks if WebSocket and SSE connections are still active
- Added `connectionLivenessInterval` and `connectionLivenessTimeout` configuration options to the actor lifecycle settings
- Enhanced the `Conn` class with liveness tracking and checking capabilities
- Added `getConnectionReadyState` method to connection drivers to report connection status
- Created a test actor (`connLivenessActor`) and test suite to verify liveness functionality
- Implemented internal event scheduling for periodic liveness checks
- Added timestamp tracking for last seen activity on connections

### How to test?

The PR includes a comprehensive test suite in `actor-conn.ts` that verifies:
1. Connections report correct liveness status
2. Dead connections are properly detected
3. Stale connections are automatically cleaned up after the timeout period
4. Active connections continue to function normally

Run the tests with:
```
pnpm test
```

### Why make this change?

WebSocket connections can become stale or disconnected without proper notification, leading to resource leaks and potential issues with connection management. This change implements a robust mechanism to detect and clean up these stale connections automatically, improving system reliability and resource utilization.

The liveness check system ensures that the actor framework maintains an accurate view of active connections and can properly manage resources by removing connections that are no longer active.
@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Aug 25, 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.

Comment thread packages/core/src/actor/instance.ts
@jog1t
Copy link
Copy Markdown
Collaborator

jog1t commented Sep 18, 2025

@joshua1 please resolve conflicts, and we can finally merge it!

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.

7 participants