-
Notifications
You must be signed in to change notification settings - Fork 24
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
Support for Browser Runtime #1144
Comments
Our libraries actually do work in browser with webpack 4 (not 5) in a so called "fallback mode" (no gRPC) and a little bit different authentication flow (OAuth2 workflow via google-auth-library, and then pass authenticated auth client to the client constructor as Important disclaimer: while I believe it should work, it's not an officially supported feature yet. |
@alexander-fenster Thanks you for answering. after i dived into the codebase, actually, so when i checked this library( for example, below is apicall method implemented in gax-nodejs (src/call.ts) /**
* Call calls the specified function. Result will be used to fulfill
* the promise.
*
* @param {SimpleCallbackFunction} func
* A function for an API call.
* @param {Object} argument
* A request object.
*/
call(func: SimpleCallbackFunction, argument: RequestType): void {
if (this.completed) {
return;
}
const canceller = func(
argument,
(
err: GoogleError | null,
response?: ResponseType,
next?: NextPageRequestType,
rawResponse?: RawResponseType
) => {
this.completed = true;
setImmediate(this.callback!, err, response, next, rawResponse);
}
);
if (canceller instanceof Promise) {
canceller.catch(err => {
setImmediate(this.callback!, new GoogleError(err), null, null, null);
});
}
this.cancelFunc = () => canceller.cancel();
}
} so every time i use this library in browser runtime, i have to resolve all the polyfills and dependencies which browser api doesn't provide. |
Yes, unfortunately, you would need some polyfills (webpack 4 will provide them for you). Here is my recent successful attempt to make the GAPIC library work in browser: https://github.com/googleapis/gax-nodejs/blob/main/test/browser-test/test/test.endtoend.ts (in |
Summary
Is there any considerations of Supporting Browser Runtime?
It will be really useful for Front-end Developers Using this library in Browser Runtime (like Chrome)
Details
Recently, I generated typescript API from my protobuf(
.proto
) file using this library.I tried to use this API in my Nextjs Project.
it works on Server Side Request(Node.js runtime) as expected,
but When requesting in the browser, it didn't work
because it depends on nodejs runtime dependencies (like
fs
,utils
,promisify
...etc)It would be really helpful for Frontend Developers if this generator supports browser runtime.
Thank you.
The text was updated successfully, but these errors were encountered: