I would not return in case of error here.
And don't forget to release the Lua callback since it will never be called:

   get_lua_context().cancel_callback(callback_ref);