mTLS fetch throwing `TypeError: Illegal invocation` when passed around
I mentioned this when starting with mTLS with Workers but wanted to circle back to it.
If you pass
For example, screenshot shows some package code that uses a generator (once bundled) and it fails on the
To fix it, we have to do
But this isn't obvious/ideal for a DX. I'm wondering if this is "just the way it is" or if it's something Workers runtime can fix/take care of?
I can create a cloudflare/workerd issue if needed too.
If you pass
env.MY_CERT.fetch around (like to a third-party library), it will throw a TypeError: Illegal invocation when yielded unless you manually .bind it to the env.MY_CERT context. I don't know if this is specific to being used within a generator or if it does it on await too.For example, screenshot shows some package code that uses a generator (once bundled) and it fails on the
yield.To fix it, we have to do
options.fetcher = env.MY_CERT.fetch.bind(env.MY_CERT)But this isn't obvious/ideal for a DX. I'm wondering if this is "just the way it is" or if it's something Workers runtime can fix/take care of?
I can create a cloudflare/workerd issue if needed too.
