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

sql_instances_service.export.js documentation is incomplete and my implementation is throwing a Received RST_STREAM with code 0 error #5112

Closed
ericdrosas87 opened this issue Mar 6, 2024 · 2 comments
Assignees

Comments

@ericdrosas87
Copy link

Environment details

  • which product (packages/*): "@google-cloud/sql": "^0.7.0"
  • OS: GCP Cloud Shell
  • Node.js version: v20.11.0
  • npm version: v10.4.0
  • google-cloud-node version: (same as above, this is in Cloud Shell)

Steps to reproduce

I've modified the code as such:

    const instance = 'my-instance'
    /**
     *  Project ID of the project that contains the instance to be exported.
     */
    const project = 'my-project';
    /**
     */
    const body = { 
      exportContext: {
        uri: "gs://my-bucket/my-sub-bucket/test.sql",
        databases: ["database_name"],
        fileType: "SQL"
      }
     }
  
    // Imports the Sql library
    const {SqlInstancesServiceClient} = require('@google-cloud/sql').v1;
  
    // Instantiates a client
    const sqlClient = new SqlInstancesServiceClient();
  
    async function callExport() {
      // Construct request
      const request = {
        instance, project, body
      };
  
      // Run request
      let response = await sqlClient.export(request);
      console.log(response);

    }
  
    callExport();

There's virtually no useful documentation for me to read to figure out how to make this code snippet work - I've had to dig through the package source code to figure out what the request body should look like, etc. My plan is to get it working and then move it to a Cloud Function.

I'm seeing this error though:

erosas@cloudshell:~/sql-exporter-poc$ node index.js 
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: 13 INTERNAL: Received RST_STREAM with code 0
    at callErrorFromStatus (/home/erosas/sql-exporter-poc/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/home/erosas/sql-exporter-poc/node_modules/@grpc/grpc-js/build/src/client.js:192:76)
    at Object.onReceiveStatus (/home/erosas/sql-exporter-poc/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)
    at Object.onReceiveStatus (/home/erosas/sql-exporter-poc/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at /home/erosas/sql-exporter-poc/node_modules/@grpc/grpc-js/build/src/resolving-call.js:99:78
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/home/erosas/sql-exporter-poc/node_modules/@grpc/grpc-js/build/src/client.js:160:32)
    at ServiceClientImpl.<anonymous> (/home/erosas/sql-exporter-poc/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at /home/erosas/sql-exporter-poc/node_modules/@google-cloud/sql/build/src/v1/sql_instances_service_client.js:218:29
    at /home/erosas/sql-exporter-poc/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
    at OngoingCallPromise.call (/home/erosas/sql-exporter-poc/node_modules/google-gax/build/src/call.js:67:27)
    at NormalApiCaller.call (/home/erosas/sql-exporter-poc/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)
    at /home/erosas/sql-exporter-poc/node_modules/google-gax/build/src/createApiCall.js:108:30
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 13,
  details: 'Received RST_STREAM with code 0',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

Node.js v20.11.0
@sofisl sofisl self-assigned this Mar 12, 2024
@davidfiala
Copy link

davidfiala commented Apr 18, 2024

Solution: #4679 (comment)

change: new SqlInstancesServiceClient(); to: new SqlInstancesServiceClient({fallback:'rest'});

Note to the maintainers: This is a pretty bad experience and a can be a significant time sink. Until a full fix is available, please consider immediately patching and releasing an update to apply this falllback automatically if that is a possible solution that won't break other things.

@sofisl
Copy link
Contributor

sofisl commented May 1, 2024

Thank you for the solution @davidfiala

FYI, it is described in the sample.

Unfortunately this API only has rest transport; I agree it's not an ideal experience but it is a unique one, our other APIs work without specifying rest transport. Hopefully people will find this issue when using this API.

@sofisl sofisl closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants