question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StreamInterceptor type doesn't support Promise intercept

See original GitHub issue

The 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:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
someone1commented, Nov 19, 2020

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 created Promise 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.

0reactions
kurnal-voltcommented, Sep 24, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found