JavaScript: GP Task being called multiple times

4099
1
Jump to solution
01-08-2015 02:17 PM
NatalieScott1
New Contributor III

I have a GP task that is called within a JS webpage. When I click the button to run the task, it frequently starts up multiple version of the task as shown in the following console logs:

 

(for context, FP13 is the js page; line 927 is "console.log(jobInfo.jobStatus);" and the '2' or other number that sometimes occurs in front of the output indicates that that statement has been console.logged that many times in succession)

 

2FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

2FP13.js:927 esriJobSubmitted

2FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

2FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

2FP13.js:927 esriJobExecuting

2FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

2FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

2FP13.js:927 esriJobSubmitted

2FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSubmitted

31FP13.js:927 esriJobExecuting

FP13.js:927 esriJobFailed

FP13.js:932 esriJobFailed

19FP13.js:927 esriJobExecuting

FP13.js:927 esriJobSucceeded

FP13.js:932 esriJobSucceeded (etc etc)

 

So you can see that the task was sumbitted multiple times and is running many of these concurrently. Some of them succeed, some of them fail. There is no consistency to the number of times a job is sumbitted - it might be once, twice, or any number.

 

The GP task is called with: gpEvent.submitJob(paramsEvent, eventCompleteCallback, eventStatusCallback);

The parameters are unlikely to be the problem because doesn't behave consistently even when the parameters are identical.

 

Has anyone come across this behaviour before? And how do I fix it?

 

I am running the GP service from a 10.2.1 server and testing primarily in Chrome using the 3.11 API build.

 

Many thanks!

Natalie    

0 Kudos
1 Solution

Accepted Solutions
NatalieScott1
New Contributor III

I worked this out. The on-click event that called the GP tool was being wired as part of another button (Button B), so if Button B was clicked multiple times in one session, multiple on-click events were set up and would trigger simultaneously. Very annoying but a good lesson in code management!

View solution in original post

0 Kudos
1 Reply
NatalieScott1
New Contributor III

I worked this out. The on-click event that called the GP tool was being wired as part of another button (Button B), so if Button B was clicked multiple times in one session, multiple on-click events were set up and would trigger simultaneously. Very annoying but a good lesson in code management!

0 Kudos