Skip to content

Consecutive InvokeServerAsync / Fire calls dont work properly #42

@Aspecky

Description

@Aspecky

Server:

local BridgeNet = require(game.ReplicatedStorage.Packages.bridgenet2)

BridgeNet.ServerBridge("Test").OnServerInvoke = function(player)
    return BridgeNet.CreateUUID()
end

Client:

local BridgeNet = require(game.ReplicatedStorage.Packages.bridgenet2)

task.defer(function()
    warn("STARTING FIRST")
    while true do
        local reply = BridgeNet.ClientBridge("Test"):InvokeServerAsync()
        print("1:", reply)
    end
end)

task.defer(function()
    warn("STARTING SECOND")
    while true do
        local reply = BridgeNet.ClientBridge("Test"):InvokeServerAsync()
        print("2:", reply)
    end
end)

The above code will result in the second thread invoking but never returning, so it'll infinite yield at the first invoke while the first thread will keep working as expected:

  10:52:14.455  [BridgeNet2] Loading server version 1.0.0  -  Server - Output:17
  10:52:14.455  [BridgeNet2] Loaded  -  Server - Output:17
  10:52:15.830  [BridgeNet2] Loading client version 1.0.0  -  Client - Output:17
  10:52:15.830  [BridgeNet2] Loaded  -  Client - Output:17
  10:52:15.862  STARTING FIRST  -  Client - Test:4
  10:52:15.862  STARTING SECOND  -  Client - Test:12
  10:52:17.633  1: 3047E7CB807E429B8AF8A6CEF36EBBDD  -  Client - Test:7
  10:52:17.709  1: 6B75EB5E5B314742817B6B1D60F47465  -  Client - Test:7
  10:52:17.794  1: 3BB2375D8EF74EC48DAB2E957EC63C53  -  Client - Test:7
  10:52:17.865  1: C3C6966FB9AE4ABBADB0A882738B40A6  -  Client - Test:7
  10:52:17.943  1: B99283E4A61B43DFB0BA8266398CDDD0  -  Client - Test:7

That behavior should be a bug because doing the same with roblox RemoteFunctions works as expected.


And while trying to find a workaround, I came across another bug:

Server:

local BridgeNet = require(game.ReplicatedStorage.Packages.bridgenet2)

BridgeNet.ServerBridge("Test"):Connect(function(player, id)
    BridgeNet.ServerBridge("Test"):Fire(player, id)
end)

Client:

local BridgeNet = require(game.ReplicatedStorage.Packages.bridgenet2)

task.defer(function()
    warn("STARTING FIRST")
    while true do
        local id = math.random()
        BridgeNet.ClientBridge("Test"):Fire(id)
        local reply = BridgeNet.ClientBridge("Test"):Wait()
        warn("1:", reply == id)
    end
end)
task.defer(function()
    warn("STARTING SECOND")
    while true do
        local id = math.random()
        BridgeNet.ClientBridge("Test"):Fire(id)
        local reply = BridgeNet.ClientBridge("Test"):Wait()
        warn("2:", reply == id)
    end
end)

while the prints would pretty much always be false that's to be expected, the issue is this error that comes with it:

  11:24:13.339  [BridgeNet2] Loading server version 1.0.0  -  Server - Output:17
  11:24:13.339  [BridgeNet2] Loaded  -  Server - Output:17
  11:24:14.894  [BridgeNet2] Loading client version 1.0.0  -  Client - Output:17
  11:24:14.895  [BridgeNet2] Loaded  -  Client - Output:17
  11:24:14.931  STARTING FIRST  -  Client - Test:4
  11:24:14.932  STARTING SECOND  -  Client - Test:13
  11:24:16.793  1: true  -  Client - Test:9
  11:24:16.793  ReplicatedStorage.Packages._Index.ffrostflame_bridgenet2@1.0.0.bridgenet2.Client.ClientBridge:281: attempt to call missing method 'Disconnect' of table  -  Client - ClientBridge:281
  11:24:16.793  Stack Begin  -  Studio
  11:24:16.793  Script 'ReplicatedStorage.Packages._Index.ffrostflame_bridgenet2@1.0.0.bridgenet2.Client.ClientBridge', Line 281  -  Studio - ClientBridge:281
  11:24:16.793  Script 'ReplicatedStorage.Packages._Index.ffrostflame_bridgenet2@1.0.0.bridgenet2.Client.ClientBridge', Line 192  -  Studio - ClientBridge:192
  11:24:16.794  Script 'ReplicatedStorage.Packages._Index.ffrostflame_bridgenet2@1.0.0.bridgenet2.Utilities.RecycledSpawn', Line 6 - function passer  -  Studio - RecycledSpawn:6
  11:24:16.794  Script 'ReplicatedStorage.Packages._Index.ffrostflame_bridgenet2@1.0.0.bridgenet2.Utilities.RecycledSpawn', Line 12 - function yielder  -  Studio - RecycledSpawn:12
  11:24:16.794  Stack End  -  Studio
  11:24:16.794  1: false  -  Client - Test:9

the error wouldnt actually break any code (i think) which is good but it's still an error and ideally shouldnt exist.

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