I am building a forge app with creates Jira issues periodically. I am facing Platform unexpected error
. I am using try catch
but this error sometimes is not caught in the catch block. I am checking if there is any operation that is consuming more memory.
Meanwhile, what is the recommended approach to handle this error as it is not caught in the catch block and is not retrying the event automatically?
How do I debug to find the root cause of this error?
Hi @SagarGujarati,
If you could share the code which doesn’t work it would be helpful. Please keep in mind that catch block is executed when an error is thrown and if you use promises to make a REST API call, you may want to do this:
api.asApp().requestJira(path)
.catch(error => { /* handle error */ })
Thanks,
Vitalii
Hi @vpetrychuk
I am using google-auth-library
for google API authentication. Below is the code snippet.
import { auth } from "google-auth-library";
import { storage } from "@forge/api";
import { AUTH_SCOPES } from "../../constants";
export const authenticate = async (credentials) => {
try {
const authJson = typeof credentials === "object" ? credentials : JSON.parse(credentials);
const client = auth.fromJSON(authJson);
client.scopes = AUTH_SCOPES;
const resp = await client.authorize();
await storage.setSecret("authToken", resp.access_token);
return true;
}
catch (err) {
console.error(`Error in Authentication : ${err.message}`);
return false;
}
};
Have you followed the instructions from https://developer.atlassian.com/platform/forge/manifest-reference/permissions/#external-permissions? It looks like the request you make inside the try block is timing out accordingly to What does a "Platform unexpected error" mean in a Jira Forge App
I’d suggest adding console.log
after each line to figure out which one “hangs” and then troubleshoot it.
Thanks,
Vitalii
1 Like