googleapis / nodejs-resource-manager

This repository is deprecated. All of its content and history has been moved to googleapis/google-cloud-node.
https://cloud.google.com/resource-manager/
Apache License 2.0
22 stars 20 forks source link

Received RST_STREAM with code 0 when using createProject() #427

Closed dinhanhthi closed 2 years ago

dinhanhthi commented 2 years ago

Hi everyone,

I've a problem when using ProjectsClient.createProject() to create a new project. I've used the example codes provided in the reference,

const [operation] = await resourcemanagerClient.createProject(request);
const [response] = await operation.promise();

However, there is alway an error on the second command,

Error: 13 INTERNAL: Received RST_STREAM with code 0
    at Object.callErrorFromStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
    at Object.onReceiveStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/client.js:180:52)
    at Object.onReceiveStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141)
    at Object.onReceiveStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)
    at /Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/call-stream.js:160:78
    at processTicksAndRejections (node:internal/process/task_queues:76:11) {
  code: 13,
  details: 'Received RST_STREAM with code 0',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

According to this guide, it's a long-running operation, I know that and I've tried with ProjectsClient. checkCreateProjectProgress() (ref). However, the same problem occurs,

Error: 13 INTERNAL: Received RST_STREAM with code 0
    at Object.callErrorFromStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
    at Object.onReceiveStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/client.js:180:52)
    at Object.onReceiveStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141)
    at Object.onReceiveStatus (/Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)
    at /Users/thi/git/OTHERS/google-api-playground/node_modules/@grpc/grpc-js/build/src/call-stream.js:160:78
    at processTicksAndRejections (node:internal/process/task_queues:76:11) {
  code: 13,
  details: 'Received RST_STREAM with code 0',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} },
  note: 'Exception occurred in retry method that was not classified as transient'
}

Moreover, the project is well created on the cloud but the problem is I don't know when it's finished to continue my task.

Environment details

Steps to reproduce

Create a file createProject.js with the following content,

import { credentials, parent } from "../credentials.js";
import { ProjectsClient } from "@google-cloud/resource-manager";

function main(projectId, displayName = "New Project") {
  const resourcemanagerClient = new ProjectsClient({ credentials });
  const project = { parent, projectId, displayName };
  async function callCreateProject() {
    const [operation] = await resourcemanagerClient.createProject({ project });
    const [response] = await operation.promise();
    console.log(response);
  }
  callCreateProject();
}

Then call,

node -r dotenv/config createProject.js <project-id>
sofisl commented 2 years ago

Hi @dinhanhthi,

I could not successfully replicate your issue. For reference, I used this code (slightly modified from here):

function main(projectId, displayName) {
  // [START cloudresourcemanager_v3_generated_Projects_CreateProject_async]

  // Imports the Resourcemanager library
  const {ProjectsClient} = require('@google-cloud/resource-manager').v3;

  // Instantiates a client
  const resourcemanagerClient = new ProjectsClient();

  async function callCreateProject() {
    // Construct request
    const request = {
      project: {
        projectId,
        displayName
      },
    };

    console.log(request)
    // Run request
    const [operation] = await resourcemanagerClient.createProject(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callCreateProject();
  // [END cloudresourcemanager_v3_generated_Projects_CreateProject_async]
}

process.on('unhandledRejection', err => {
  console.error(err.message);
  process.exitCode = 1;
});
main(...process.argv.slice(2));

Some troubleshooting ideas I have:

1) Can you post your credentials.js file (with all values redacted?) I authenticated with application default credentials, but there are many ways to authenticate; I'm just not familiar with the way in which you are authenticating.

2) Can you attempt to create a project outside of the parent organization? You may be attempting to create a project in an organization that has some restrictions, and it may just be giving you a bad error message.

sofisl commented 2 years ago

Closing due to inactivity, please feel free to reopen if it continues to be a problem.