StreamInterceptor type doesn't support Promise intercept
See original GitHub issueThe following won’t compile but should/does work:
import {
StreamInterceptor,
} from 'grpc-web';
const streamAuthInterceptor: StreamInterceptor<unknown, unknown> = {
async intercept(request, invoker) {
await authRequest(request);
return invoker(request);
},
};
removing the StreamInterceptor
type from the variable lets it compile and it behaves as expected (adding the appropriate metadata to the request)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Angular Interceptor test with a promise failing - Stack Overflow
I am having an issue with a unit test for one of my Interceptors whereas I get the following error when the test...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
In our case, we need to register the intercept before visiting the page. Once the page is loaded, the application fetches the todo...
Read more >Intercepting JavaScript Fetch API requests and responses
The Fetch API doesn't support interceptors natively. However, there are other libraries for making HTTP calls that support interceptors. Take a ...
Read more >Interceptors | NestJS - A progressive Node.js framework
Each interceptor implements the intercept() method, which takes two arguments. ... Observable<T> (supporting the response stream), and R is the type of the ......
Read more >Setting up Axios Interceptors for all HTTP calls in an application
But it doesn't have to be. With the help of the popular JavaScript HTTP client Axios, you can set up interceptor functions to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can confirm that I did need to implement a non-promise version of the interceptor for the
streamInterceptors
options - reusing the unary interceptor option createdPromise
returns on all stream calls which was not what the types were expecting.Again, since the token expiration/refresh is handled from a 3rd party that relies on Promises, it’d be ideal that the interceptor supported Promise-based functions.
any updates on this? why hasn’t this been addressed yet as it seems to be a good use case I am running into also