Skip to content
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

feat: implementation of useAbortSignal option for grpc-web #777

Merged
merged 7 commits into from
Feb 22, 2023

Conversation

hersentino
Copy link
Contributor

#731 introduces the useAbortSignal option but it's currently not implemented for grpc-web.

This PR add useAbortSignal for grpc-web, fully working with unary/invoke

@hersentino
Copy link
Contributor Author

I'm trying to figure out why build (16.x) is failing

@hersentino hersentino marked this pull request as draft February 10, 2023 16:38
@hersentino hersentino marked this pull request as ready for review February 13, 2023 10:03
@stephenh
Copy link
Owner

Hi @hersentino , thanks for the PR! I think this looks great!

I'm trying to figure out why build (16.x) is failing

Ah yeah, sorry for not replying sooner but oddly enough CircleCL will cancel all jobs once the first one fails, so a lot of times the issue will look (say) specific to the 16.x build, but really it just happened to fail first, and the issue does actually exist in all versions of node.

I think your changes look good; as a regression test, can you find an example integration/* directory that is using grpc-web and add the useAbortSignal=true method to its parameters.txt? After running yarn bin2ts, you should see the generated code from your changes, which we include in PRs + as part of CI. Thanks!

src/generate-grpc-web.ts Outdated Show resolved Hide resolved
@stephenh
Copy link
Owner

stephenh commented Feb 13, 2023

Fwiw @hersentino I think landing this PR is still great; but when I went to google "improbable-eng abort signal" to sanity check how it works, and I came across nice-grpc-web:

https://www.npmjs.com/package/nice-grpc-web

Which is a sister project/built on top of ts-proto.

I was scanning their impl and nothing stuck out as me as something we should borrow/replicate for your PR:

https://github.com/deeplay-io/nice-grpc/blob/master/packages/nice-grpc-web/src/client/createUnaryMethod.ts

Which is cool, we can ship your PR as-is, but just thought I'd mention it, since they are actively using ts-proto + grpc-web, it might be worth checking out.

@hersentino
Copy link
Contributor Author

can you find an example integration/* directory that is using grpc-web and add the useAbortSignal=true method to its parameters.txt ?

I chose integretion/grpc-web-no-streaming-observable because it contains unary method. But might it be better if I create a new example directory just for useAbortSignal option ? It could test the 3 methods createPromiseUnaryMethod, createObservableUnaryMethod and createInvokeMethod

@hersentino
Copy link
Contributor Author

hersentino commented Feb 14, 2023

since they are actively using ts-proto + grpc-web, it might be worth checking out.

It seems to be handle here execute.

They don't use the close method from the client. I'm trying to understand how it works without, I don't a have lot a time right now but I should test locally nice-grpc-web to fully understand the behavior

@hersentino
Copy link
Contributor Author

I'm sorry @stephenh I forgot to ping you

UserSettings(request: DeepPartial<Empty>, metadata?: grpc.Metadata): Observable<DashUserSettingsState>;
UserSettings(
request: DeepPartial<Empty>,
abortSignal?: AbortSignal,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hersentino this seems fine, but it's probably a breaking API change to current codes that are passing foo.UserSettings(request, metadata)?

Can we push the abortSignal last so that it's not a breaking change?

Copy link
Contributor Author

@hersentino hersentino Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephenh Yep no problem :)

I initially put it in second argument because it was set as 2nd argument in this PR

So I had to also push abortSignal to last argument for the function generateService inside src/generate-services.ts. Not sur if this modification break something somewhere else.

@stephenh
Copy link
Owner

@hersentino looks great! Thanks!

@stephenh stephenh merged commit 7a3d429 into stephenh:main Feb 22, 2023
stephenh pushed a commit that referenced this pull request Feb 24, 2023
# [1.140.0](v1.139.0...v1.140.0) (2023-02-24)

### Features

* `removeEnumPrefix` option ([#779](#779)) ([53733e6](53733e6))
* implementation of useAbortSignal option for grpc-web ([#777](#777)) ([7a3d429](7a3d429))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.140.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants