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

TypeScript compilation issue: No exported member 'SubchannelCallStatsTracker' #2345

Closed
justinpinili opened this issue Feb 6, 2023 · 7 comments

Comments

@justinpinili
Copy link

Problem description

node_modules/@grpc/grpc-js/build/src/call-stream.d.ts:9:10 - error TS2305: Module '"./subchannel"' has no exported member 'SubchannelCallStatsTracker'.

Unable to compile due to no exported member SubchannelCallStatsTracker

Reproduction steps

Any version of grpc/grpc-node at 1.8.1 and higher causes any dependent service/package to not compile successfully

Environment

  • Node version: v14.19.3
  • Node installation method nvm
  • Package name and version: grpc/grpc-node version 1.8.1 and above

Additional context

node_modules/@grpc/grpc-js/build/src/call-stream.d.ts:9:10 - error TS2305: Module '"./subchannel"' has no exported member 'SubchannelCallStatsTracker'.

9 import { SubchannelCallStatsTracker, Subchannel } from './subchannel';
@murgatroid99
Copy link
Member

What code of yours triggered this error? I see the vestigial generated code in the package, but a simple script that just imports from the @grpc/grpc-js package compiles without errors.

@justinpinili
Copy link
Author

Nothing in our code explicitly references the SubchannelCallStatsTracker or the ./subchannel file at all. I'm seeing this happen when we try to compile our internal packages before running our unit test in the cd pipeline.

The import statements I'm seeing in our library are the following:

// file 1
import { Interceptor, InterceptorOptions, Requester, Metadata } from '@grpc/grpc-js';
import { InterceptingListener, Listener } from '@grpc/grpc-js/build/src/call-stream';
import { InterceptingCall, NextCall } from '@grpc/grpc-js/build/src/client-interceptors'

// file 2
import { credentials, ClientOptions } from '@grpc/grpc-js';

// file 3
import { Metadata, Requester } from '@grpc/grpc-js';

@murgatroid99
Copy link
Member

This one is the problem: import { InterceptingListener, Listener } from '@grpc/grpc-js/build/src/call-stream';. The error you quoted is on a line in node_modules/@grpc/grpc-js/build/src/call-stream.d.ts. The root cause is that call-stream was removed in version 1.8.x. In general, importing from internal files in the library is not supported, and there is no guarantee that the API will be stable.

@tpeplinx
Copy link

tpeplinx commented Feb 8, 2023

So what is the recommended way to implement custom interceptors with own logic for the methods below?

  • onReceiveMessage
  • onReceiveMetadata
  • onReceiveStatus

@murgatroid99
Copy link
Member

Listener and InterceptingCall are part of the public API, so you can access them without importing from internal files. Other than that, if you feel that you need a type that isn't in the public API to use part of the public API, file an issue so that we can fix it.

@murgatroid99
Copy link
Member

#2351 will add InterceptingListener and NextCall. If this comes up in the future, file another issue that specifies what types you need.

@murgatroid99
Copy link
Member

Version 1.8.8 exports the InterceptingListener and NextCall types.

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

No branches or pull requests

3 participants