Skip to content

Error while setting the response protocol via Lua script #393

@Rishabh-Daga

Description

@Rishabh-Daga

Description

There is an error occurring while setting the response protocol of Redis to RESP3 via a Lua script in the main.go file.

Steps to Reproduce

  1. Start a miniredis server.
  2. Connect to the miniredis server with RESP3.
  3. Run the Lua script to set the response protocol.

Code

package main

import (
	"context"
	"fmt"
	"github.com/alicebob/miniredis/v2"
	"github.com/redis/go-redis/v9"
)

func main() {

	// Start a miniredis server
	mr, err := miniredis.Run()
	if err != nil {
		fmt.Printf("error in starting miniredis: %s\n", err)
		return
	}
	defer mr.Close()

	// Connect to the miniredis server with RESP3
	redisClient := redis.NewClient(&redis.Options{
		Addr:     mr.Addr(),
		Protocol: 3,
	})

	luaScript := `-- Use RESP3
redis.setresp(3)`

	// Run the lua script
	res, err := redis.NewScript(luaScript).Run(context.Background(), redisClient, []string{}).Result()
	if err != nil {
		fmt.Printf("error in setting the response protocol: %s\n", err)
		return
	}

	fmt.Println("Response: ", res)
}

Expected Behavior

The Lua script should set the response protocol to RESP3 without any errors.

Actual Behavior

The below error occurs while setting the response protocol.
ERR Error compiling script (new function): :2: attempt to call a non-function object stack traceback: :2: in main chunk [G]: ?

Environment

  • Go version: 1.23.4
  • github.com/alicebob/miniredis/v2 version: v2.34.0
  • github.com/redis/go-redis/v9 version: v9.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions