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

grpc-js: Speculative fix for ECONNRESET errors #1705

Conversation

murgatroid99
Copy link
Member

A couple of people in googleapis/nodejs-firestore#1023 have reported calls ending with INTERNAL errors triggered by an underlying error that says "read ECONNRESET". Those should be reported as UNAVAILABLE. My guess is that Node is reporting these errors in the form of a SystemError with the code ECONNRESET. If that is the case, we can distinguish those errors and change the code. I also added some logging for the errors from Node to hopefully get a better idea of the error structure if this doesn't work.

If that information isn't actually available in a structured way in the error, we might have to fall back to parsing the error message but I really hope we can avoid that because those messages are supposed to be human-readable, not machine-parseable.

@forconz
Copy link

forconz commented Sep 10, 2021

[email protected] demo
.\node_modules.bin\ts-node .\src\main.ts

D:\Projects\Test\helloworld\node_modules@grpc\grpc-js\src\call.ts:81
return Object.assign(new Error(message), status);
^
Error: 14 UNAVAILABLE: read ECONNRESET
at Object.callErrorFromStatus (D:\Projects\Test\helloworld\node_modules@grpc\grpc-js\src\call.ts:81:24)
at Object.onReceiveStatus (D:\Projects\Test\helloworld\node_modules@grpc\grpc-js\src\client.ts:338:36)
at Object.onReceiveStatus (D:\Projects\Test\helloworld\node_modules@grpc\grpc-js\src\client-interceptors.ts:426:34)
at Object.onReceiveStatus (D:\Projects\Test\helloworld\node_modules@grpc\grpc-js\src\client-interceptors.ts:389:48)
at D:\Projects\Test\helloworld\node_modules@grpc\grpc-js\src\call-stream.ts:276:24
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
code: 14,
details: 'read ECONNRESET',
metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

the error code is 14
grpc-js: How to resolve ECONNRESET errors?

The Grpc service work well , I test it by BloomRPC
20210910214824

grpc-client.ts

import * as grpc from "@grpc/grpc-js";
import {PadBotGrpcServiceClient} from './grpc/wechat_grpc_pb';
export default new PadBotGrpcServiceClient('localhost:44392', grpc.credentials.createInsecure());

getTestKeyword.ts

import { TestKeywordRequest, TestKeywordResponse } from './grpc/wechat_pb';
import grpcClient from './grpc-client';

export default async () => {
  return new Promise<TestKeywordResponse>((resolve, reject) => {
    const request = new TestKeywordRequest();
    var metadata = {};

    grpcClient.getTestKeyword(request, metadata, (err, response) => {
      if (err){
        // debug(`[getTestKeyword] err:\nerr.message: ${err.message}\nerr.stack:\n${err.stack}`);
        reject(err);
        return;
      } 
      // log(`[getTestKeyword] TestKeywordResponse: ${JSON.stringify(response.toObject())}`);
      if(response)
      {
        const keyword = response.getKeyword();
        console.log(`keyword = ${keyword}`);
        resolve(response);
      } 
    });
  });
}

main.ts

import getTestKeyword from './getTestKeyword';
const main = async () => {
  await getTestKeyword();
}
  
main();

The code above throw ECONNRESET errors.

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

Successfully merging this pull request may close these issues.

3 participants