serverless-redis-http
serverless-redis-http copied to clipboard
(CaseClauseError) no case clause matching: :ok
I am using SRH to test locally an implementation using Upstash Redis, but I can't make it work.
A brief context: I'm running a serverless function on Supabase Edge Functions (this is working locally using Docker).
The code is written in Typescript using Deno. I omitted some code for simplicity.
Deno.serve(async (_req) => {
const redis = new Redis({
url: Deno.env.get("UPSTASH_REDIS_REST_URL"),
token: Deno.env.get("UPSTASH_REDIS_REST_TOKEN"),
});
// (...) omitted code
for (const mention of mentions) {
const exists = await redis.exists(mention.cid);
if (exists) {
continue;
}
// (...) omitted code
await redis.set(target.cid, "reposted");
}
return new Response({ message: "Processing done" }, {
headers: { "Content-Type": "application/json" },
});
});
My docker-compose.yml is configured like the instructions on the README.
services:
redis:
image: redis:latest
ports:
- "6379:6379"
serverless-redis-http:
ports:
- "8079:80"
image: hiett/serverless-redis-http:latest
env_file: .env
environment:
SRH_MODE: env
SRH_TOKEN: ${UPSTASH_REDIS_REST_TOKEN}
SRH_CONNECTION_STRIN: redis://redis:6379
When trying to connect using the Redis client, I'm getting this Elixir error on SRH Container
serverless-redis-http-1 | 17:40:27.032 [error] #PID<0.1119.0> running Srh.Http.BaseRouter (connection #PID<0.1118.0>, stream id 1) terminated
serverless-redis-http-1 | Server: host.docker.internal:8079 (http)
serverless-redis-http-1 | Request: POST /pipeline
serverless-redis-http-1 | ** (exit) an exception was raised:
serverless-redis-http-1 | ** (CaseClauseError) no case clause matching: :ok
serverless-redis-http-1 | (srh 0.1.0) lib/srh/http/command_handler.ex:178: Srh.Http.CommandHandler.dispatch_command/2
serverless-redis-http-1 | (srh 0.1.0) lib/srh/http/command_handler.ex:72: Srh.Http.CommandHandler.dispatch_command_array/3
serverless-redis-http-1 | (srh 0.1.0) lib/srh/http/base_router.ex:39: Srh.Http.BaseRouter.do_command_request/2
serverless-redis-http-1 | (srh 0.1.0) lib/plug/router.ex:246: anonymous fn/4 in Srh.Http.BaseRouter.dispatch/2
serverless-redis-http-1 | (telemetry 1.1.0) /app/deps/telemetry/src/telemetry.erl:320: :telemetry.span/3
serverless-redis-http-1 | (srh 0.1.0) lib/plug/router.ex:242: Srh.Http.BaseRouter.dispatch/2
serverless-redis-http-1 | (srh 0.1.0) lib/srh/http/base_router.ex:1: Srh.Http.BaseRouter.plug_builder_call/2
serverless-redis-http-1 | (plug_cowboy 2.5.2) lib/plug/cowboy/handler.ex:12: Plug.Cowboy.Handler.init/2
A note about the log: it is pointing to host.docker.internal because my Serverless Function is running on a separated network.
Any thoughts?
Hm, interesting that it's hitting the /pipeline endpoint, but your commands are directly with the client. Do you have automatic pipelining turned on? Is there a way to turn that off on the upstash client?
I will investigate further, but that might be a starting point to see if it's something to do with that (and may not be an issue on the normal endpoint, or if is, will provide further clarity)
@hiett I tried your suggestion.
When creating my Redis client I set the pipeline to false, but I am still facing the same issue.
const redis = Redis.fromEnv({
enableAutoPipelining: false,
});
serverless-redis-http-1 | 20:19:44.332 [error] #PID<0.1108.0> running Srh.Http.BaseRouter (connection #PID<0.1107.0>, stream id 1) terminated
serverless-redis-http-1 | Server: host.docker.internal:8079 (http)
serverless-redis-http-1 | Request: POST /
serverless-redis-http-1 | ** (exit) an exception was raised:
serverless-redis-http-1 | ** (CaseClauseError) no case clause matching: :ok
serverless-redis-http-1 | (srh 0.1.0) lib/srh/http/command_handler.ex:178: Srh.Http.CommandHandler.dispatch_command/2
serverless-redis-http-1 | (srh 0.1.0) lib/srh/http/base_router.ex:39: Srh.Http.BaseRouter.do_command_request/2
serverless-redis-http-1 | (srh 0.1.0) lib/plug/router.ex:246: anonymous fn/4 in Srh.Http.BaseRouter.dispatch/2
serverless-redis-http-1 | (telemetry 1.1.0) /app/deps/telemetry/src/telemetry.erl:320: :telemetry.span/3
serverless-redis-http-1 | (srh 0.1.0) lib/plug/router.ex:242: Srh.Http.BaseRouter.dispatch/2
serverless-redis-http-1 | (srh 0.1.0) lib/srh/http/base_router.ex:1: Srh.Http.BaseRouter.plug_builder_call/2
serverless-redis-http-1 | (plug_cowboy 2.5.2) lib/plug/cowboy/handler.ex:12: Plug.Cowboy.Handler.init/2
serverless-redis-http-1 | (cowboy 2.9.0) /app/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
The project is up and running on production, and working correctly with the prod Upstash Redis.
Hi! Has a solution been found?