-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
twirp-transport: Guard access of response.type to support Cloudflare Workers #321
Conversation
Fetch responses in Cloudflare Workers currently throw an error on access of the "type" property[^1][^2]. This commit guards access of the type property with a try/catch so that twirp clients can be used inside of Cloudflare Workers. [^1]: https://developers.cloudflare.com/workers/runtime-apis/response/#properties [^2]: https://github.com/cloudflare/miniflare/blob/72f046e/packages/core/src/standards/http.ts#L646
It's unclear to me why the CI run failed, but it doesn't appear to be related to the code I changed — the twirp-transport tests all pass, error is in @protobuf-ts/test-generated (which doesn't fail for me when I run it locally):
|
This is #321, but applied to the grpcweb-transport as well. All tests pass locally.
Hey @mikeylemmon, I tried it locally and don't see the test failure either. CI must have been a timing-related fluke 🤔 The code looks solid, thank you for this! |
Applied the same workaround to the grpcweb-transport in #329 |
Released in v2.7.0. |
Fetch responses in Cloudflare Workers currently throw an error on access of the "type" property12. This PR guards access of the property with a try/catch so that twirp clients can be used inside of Cloudflare Workers.
Footnotes
https://developers.cloudflare.com/workers/runtime-apis/response/#properties ↩
https://github.com/cloudflare/miniflare/blob/72f046e/packages/core/src/standards/http.ts#L646 ↩