Error in onJobPostingUpdate and can't install\uninstall custom app in Freshteam

Hi all. I have two problem with serverless app for freshteam.
Simple app:

manifest.json
{
	"platform-version": "2.0",
	"product": {
		"freshteam": {}
	},
	"dependencies": {
		"axios": "0.21.1"
	},
	"whitelisted-domains": [
		"https://*.freshteam.com",
		"http://[REDACTED].jooble.org",
		"https://[REDACTED].jooble.org"
	]
}
server.js
var axios = require("axios");
axios.defaults.headers.post["Content-Type"] = "application/json; charset=utf-8";

exports = {
	events: [
		{ event: "onAppUninstall", callback: "onAppUninstallHandler" },
		{ event: "onJobPostingCreate", callback: "onJobPostingCreateHandler" },
		{ event: "onJobPostingUpdate", callback: "onJobPostingUpdateHandler" }
	],

	onAppUninstallHandler: function (args) {
		var data = {
			domain: args.domain
		};
		HandleData("/Freshteam/AppUninstall", data);
	},

	onJobPostingCreateHandler: function (args) {
		if (args.data.jobposting.status === "published") {
			var data = {
				domain: args.domain,
				title: args.data.jobposting.title,
				description: args.data.jobposting.description,
				region: `${args.data.associations.branch.city}, ${args.data.associations.branch.country_code}`,
				job_type: args.data.jobposting.type,
				salary: `${args.data.jobposting.salary.min} - ${args.data.jobposting.salary.max}, ${args.data.jobposting.salary.currency}`,
				remote: args.data.jobposting.remote,
				date_posted: args.data.jobposting.created_at,
				date_expire: args.data.jobposting.closing_date,
				apply_url: args.data.jobposting.applicant_apply_link
			};
			HandleData("/Freshteam/JobPosted", data);
		} else
			renderData();
	},

	onJobPostingUpdateHandler: function (args) {
		var data = {
			domain: args.domain,
			is_deleted: args.data.jobposting.deleted,
			apply_url: args.data.jobposting.applicant_apply_link,
			changes: args.changes.model_changes
		}
		HandleData("/Freshteam/JobUpdate", data);
	}
};

function HandleData(endpoint, data) {
	axios.post(`http://[REDACTED].jooble.org${endpoint}`, data)
		.then(function (response) {
			renderData(response);
		})
		.catch(function (error) {
			renderData(error);
		});
}

Problem one:

  • When in the simulator http://localhost:10001/web/test# I press appUninstall\appInstallSimulate , there are no errors in the console window and everything works fine.
  • But next I select onJobPostingCreateSimulate, everything is done i receive data in api project, it shows Success and I get an error in the console in the screenshot below.

Perhaps this is a local problem and not a problem on the portal.

Problem two:

  1. Uploaded custom app in https://www.freshdev.io/
  2. When i try install app in freshteam portal, I get an error (Cannot read property ‘extDetail’ of undefined) in screenshot below I didn’t find it in the tech documentation about this property
  3. I tried to create an empty app, uploaded it as an integrator, we try to install it, everything worked out, I try to delete it, I get an same error in the screenshot below.

Hi @Cyber_Garret,

For problem #1, the “Cannot set headers after they are sent” error is returned when the renderData() callback is called twice in the same conditional flow.
Could you check where is it leaking by simplifying the code and execute the callback method only once and return the flow?

For problem #2, the error received during the app uninstall operation includes an error from the application code. So, could you enable debug logs in the FDK and check the logs of the issue to troubleshoot further if it’s an app issue?
Please share the relevant logs if it doesn’t seem issue from the app and I could help find the issue.

2 Likes