Attempt to yield across a C-call boundary

  1. Client (production/canary) and FXServer version
    Canary, 5592 win. (RedM, but should be the same for FiveM)

  2. What you expected to happen

  3. What actually happens

Yielding from an export called by the __pack metamethod throws attempt to yield across a C-call boundary. on the first run.

Restarting the dependency resource(the one creating the export)
and then restarting a resource that uses that export, the above error is thrown
if we restart the invoking resource again, it works fine.

  1. Category of bug (eg. client, server, weapons, peds, native)
    ScRT?

  2. Reproducible steps, preferably with example script(s)
    repro: 'attempt to yield across a C-call boundary' · GitHub

Seems like the stack has become somewhat less informative since this change

oh ok man thanks

Repro actually boils down to just:

function test()
	local EXT = 111

	msgpack.extend_clear(EXT)

	local t = setmetatable({ },
	{
		__ext = EXT,

		__pack = function(t, tag)
			
			Wait(0) -- >:(

			return json.encode(t)
		end,
	})

	print(pcall(msgpack.pack, t) and 'All good!' or 'Oh no!')
end

CreateThread(function()
    test()
end)

I know this is weird and probably a dont-do-that code, but i’ll leave it here in case its a bug or whatever.

Go test from before that update, because you’ll likely find there was little-to-no information before.

I’m sure it has improved on other cases, but in this case it used to at least throw a attempt to yield across a C-call boundary. error on the export invoking line IIRC.