Skip to content

Conversation

@Wundero
Copy link

@Wundero Wundero commented Jul 8, 2025

This PR adds a new connector type for upstash redis.

@arthberman
Copy link

@Wundero is as responsive as a regular TCP redis connection ?

@Wundero
Copy link
Author

Wundero commented Jul 17, 2025

@Wundero is as responsive as a regular TCP redis connection ?

I don't really have any numbers for it, but I suspect it's slightly slower. I doubt the difference would be noticeable but it would likely be measurable, since upstash redis uses HTTP for connections.

That being said, the purpose of this adapter isn't to improve performance, its to support the serverless usecase a bit better. Upstash's Redis client over HTTP is quite different from a standard Redis TCP socket connection, and there are incompatibilities between the two when using Upstash's product. While you can use Upstash with a normal Redis connection, if you are using the HTTP adapter in other places in your code, it makes sense to use it here as well.

The main reason I made this PR was because we are using Upstash Redis for my company's product, and we wanted to implement resumable streams for our AI chat integration. In real-world usage, it seems to be quite responsive, and we haven't run into any issues using resumable streams and Upstash together (though because this isn't in the upstream package, we have to use our own adapter).

@mandrillxx
Copy link

SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at <unknown> (../src/runtime.ts:161:33)
    at <unknown> (../src/upstash-adapters.ts:19:10)
 ⨯ unhandledRejection: SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at <unknown> (../src/runtime.ts:161:33)
    at <unknown> (../src/upstash-adapters.ts:19:10)
 ⨯ unhandledRejection:  SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at <unknown> (../src/runtime.ts:161:33)
    at <unknown> (../src/upstash-adapters.ts:19:10)

I'm getting this with your fork. Upstash Redis support would be phenomenal and a life saver, even if the latency is bad

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​upstash/​redis@​1.35.19910010099100

View full report

@Wundero
Copy link
Author

Wundero commented Aug 5, 2025

SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at <unknown> (../src/runtime.ts:161:33)
    at <unknown> (../src/upstash-adapters.ts:19:10)
 ⨯ unhandledRejection: SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at <unknown> (../src/runtime.ts:161:33)
    at <unknown> (../src/upstash-adapters.ts:19:10)
 ⨯ unhandledRejection:  SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at <unknown> (../src/runtime.ts:161:33)
    at <unknown> (../src/upstash-adapters.ts:19:10)

I'm getting this with your fork. Upstash Redis support would be phenomenal and a life saver, even if the latency is bad

@mandrillxx

I think the changes I've just pushed should hopefully address this, and it would seem upstash does some (de)serialization that other libs don't, which is why this issue can happen. Please let me know if the new stuff works for you, it seems to work for me in production but I have this particular upstash instance:

import { Redis } from "@upstash/redis";

export const redis = Redis.fromEnv({
  automaticDeserialization: false,
  readYourWrites: true,
});

@brrock
Copy link

brrock commented Aug 15, 2025

for now i use this patch that seems to work with ai sdk in convex with the latst version of this package

 diff --git a/node_modules/resumable-stream/dist/redis.js b/node_modules/resumable-stream/dist/redis.js
index 5d7fb67..e2539d9 100644
--- a/node_modules/resumable-stream/dist/redis.js
+++ b/node_modules/resumable-stream/dist/redis.js
@@ -1,22 +1,22 @@
 "use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
     if (k2 === undefined) k2 = k;
     var desc = Object.getOwnPropertyDescriptor(m, k);
     if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
-      desc = { enumerable: true, get: function() { return m[k]; } };
+        desc = { enumerable: true, get: function () { return m[k]; } };
     }
     Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
+}) : (function (o, m, k, k2) {
     if (k2 === undefined) k2 = k;
     o[k2] = m[k];
 }));
-var __exportStar = (this && this.__exportStar) || function(m, exports) {
+var __exportStar = (this && this.__exportStar) || function (m, exports) {
     for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
 };
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.createResumableStreamContext = exports.resumeStream = void 0;
 const get_redis_url_1 = require("./get-redis-url");
-const redis_1 = require("redis");
+const redis_1 = require("@upstash/redis");
 const runtime_1 = require("./runtime");
 __exportStar(require("./types"), exports);
 var runtime_2 = require("./runtime");

@brrock
Copy link

brrock commented Aug 15, 2025

i also have in a patches folder and i use patch-package to apply 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.

4 participants