progaudi/progaudi.tarantool

Handle nil (msgpack.NULL) result from lua function

anton-putau opened this issue · 0 comments

I am trying to get response from lua function and got exception with lua nil value or msgpack.NULL:

// C# code
using TaskModel = global::Tarantool.Client.Model.Tuple<int, string, string>;
using TimeOutModel = global::Tarantool.Client.Model.Tuple<string, int>;

var result = await this.box.Call<TimeOutModel, TaskModel>(TarantoolFunctionNames.TakeQueueItemFunctionName, Tuple.Create(queueName, timeout));

// Lua code
local function take_queue(queueName, timeoutSeconds)
    result = queue.tube[queueName]:take(timeoutSeconds)
    log.info("take from queue %s. result is %s", queueName, result)

    if(result == nil) then
        log.info("return NULL %s",msgpack.NULL)
        return msgpack.NULL
    end

    return result
end

Exception:

System.ArgumentException : Invalid array length: 3 is expected, but got 1. at Tarantool.Client.LogicalConnection.<SendRequestImpl>d__112.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Tarantool.Client.LogicalConnection.<SendRequest>d__72.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Tarantool.Client.Box.<Call>d__82.MoveNext()

Expected behavior: no exceptions, result.Data = empty array || null