GraphQL error on `useBits`

With isBitsEnabled reporting true, on invoking useBits our extension can get One or more GraphQL errors were detected on request 01HCYS808TQ4M1F8N58JH305HJ. IsEligible: service error. This leaves the Twitch UI panel where the purchase UI would be open but empty. The onTransactionCancelled callback is not fired.

This appears to be a Twitch internal error, it leaves the Twitch managed UI in a bad state and doesn’t allow our extension code to clean up. Also try-catch around useBits doesn’t catch this, but from logging that’s definitely where it’s failing from our code.

It seems this happens when the purchaser is the same account as the broadcaster (i.e. circular spending), but the error has not happened at least once in that scenario.

I can put in a check for viewer and broadcaster being the same before calling useBits, but I’d appreciate knowing whether this is expected behaviour or not, whether there are other circumstances that might fail in this way, and what the recommended handling for errors would be.

1 Like

Casters cannot use bits on their own channel. Either via cheering in chat or via an extension*

So this is expected.

*Except for testing scenarios, here your product is “live” hence the fail.

TBH not worth the check a caster wouldn’t ever be using their own extension to use bits unless they forgot they can’t use bits on their own channel.

Thanks for the quick reply.

For us it’s reasonable for a caster to want to check the extension, and be logged in as themselves.

I’ll add that viwer==caster check.

Flagging isBitsEnabled should be false, or something more elegant than an borked UI and untrappable error.

Ah, how would I check whether it’s their own channel. i.e. userId is a pseudonym.

window.Twitch.ext.viewer.role == broadcaster

Of course! Thanks.