Skip to content

Commit

Permalink
fix: do not hang on deploy key failure
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Jul 19, 2023
1 parent e7423aa commit b3c9686
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-crabs-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

show a descriptive error message and do not hang if there is a deploy key issue
15 changes: 9 additions & 6 deletions packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ export default class DeployCommand extends Command {
});
}

// eslint-disable-next-line @typescript-eslint/no-this-alias -- request needs it
const self = this;

const deploySubgraph = async (ipfsHash: string) => {
const spinner = print.spin(`Deploying to Graph node ${requestUrl}`);
client.request(
Expand Down Expand Up @@ -220,8 +217,11 @@ export default class DeployCommand extends Command {
$ graph create --node ${node} ${subgraphName}`;
}
}

self.error(errorMessage, { exit: 1 });
if (jsonRpcError.message.match(/auth failure/)) {
errorMessage += '\nYou may need to authenticate first.';
}
spinner.fail(errorMessage);
this.exit(1);
} else if (requestError) {
spinner.fail(`HTTP error deploying the subgraph ${requestError.code}`);
this.exit(1);
Expand Down Expand Up @@ -257,7 +257,10 @@ export default class DeployCommand extends Command {
// we are provided the IPFS hash, so we deploy directly
if (ipfsHash) {
// Connect to the IPFS node (if a node address was provided)
const ipfsClient = create({ url: appendApiVersionForGraph(ipfs.toString()), headers });
const ipfsClient = create({
url: appendApiVersionForGraph(ipfs.toString()),
headers,
});

// Fetch the manifest from IPFS
const manifestBuffer = ipfsClient.cat(ipfsHash);
Expand Down

0 comments on commit b3c9686

Please sign in to comment.