Error "Can only send one result data at a time"
Hello!
I've run into this error during a call to submitResultData :
`Can only send one result data at a time`
I attach a photo with the code and stack (line 337 is the culprit in this component).
As far as I can tell, I'm not doing that. This error also doesn't happen reliably. Only on some components, most of the time (not all the time). So I'd love anyone's advice as to what sort of things I should be looking at to troubleshoot why I'm making this happen!
All advice welcome!
Warm regards,
Dorian
Comments
Hi Dorian,
It looks like you send the result data twice in quick succession. First you send it in
on_finishand then second inon_close. Sending the result data once is enough (at least withjatos.submitResultData- if you want to append then usejatos.appendResultData). So removing one of them should solve your problem.And that this error happens not all the time is caused by the different response times to your requests. Your requests take different times each time you send them (caused by the internet speed or your server's resources). So sometimes the result data request got already a response, when you send it the second time, and sometimes not. In the latter case jatos.js throws an error because it is allowed to send only one at a time.
But if you need both,
on_finishandon_close,you have to work with the Promises jatos.js returns. I can help you with that.Best,
Kristian
Hi Kristian,
Amazing response time mate, appreciate it.
The rationale behind having the on_close is in case someone accidentally closes the browser before finishing. Try to save the data. Do you have any ideas about how to do that (easily) without this request pile up?
You mention using the promises. I don't want to create a great deal of work for this kind of paranoia. I'm happy to just risk data loss and be sure I'm saving data at time points when that data would be useful!
Warm regards,
Dorian
Hi Dorian,
actually, which JATOS version do you run on your server? Maybe a newer version can help here already.
Best,
Kristian
Yes. Good question that I'm already following up. I think a couple of the problems I'm having are version related. I might not be able to upgrade though. Depends on my department.
For your interest:
1. I ran into the issue again, with overlapping submitResultData requests. I tried to get some feedback using the returned promise:
jatos.submitResultData(resultData) .then(() => console.log('result data submitted')) .catch(() => console.log('result data submission failed'));And was told that
catchwasn't a function. This didn't matter so much, because I just wanted to see which request was returning so late, so I just deleted the catch. I think this is version related (hence my note above), but if it's not you might be interested.2. I ended up solving the overlapping requests by just putting jsPsych trials into my experiment that wait 30-60 seconds after I send a request. Not very sexy, but it gets the job done. Thanks for helping me understand the nature of the problem! I would have never gotten here elsewise.
I'm curious, is there a way to know whether it's my department's JATOS server that's slow or if it's my dev computer?
If I hear back on the version I'll let you know. Maybe we can get some closure on this.
You can get the version via jatos.version. Should give you back a string.
(I'll answer the rest later)
Version 3.3.3!
Yes, a newer JATOS version would help here. In v3.5.3 we added the 'httpLoop', that deals with this kind of problems. The current version is v3.6.1.
Nice that you could find a solution that works for you. There is no ugly solution if it does the job :).
But if you want to try out something you could also:
But it might also fail because of your older version.
And was told that
catchwasn't a function.Likely also caused by your older version.
Best,
Kristian
Yes right. Well I suspect a version update is a no go from the department. Not fast, at any rate.
I'll let you know if I ever dare to touch the code again to implement the await operator. Asynchronous stuff scares me though.
Cheers for all your help!
That's a shame. JATOS gets updates constantly. Maybe try to talk to your admin again or tell him to talk to me. Updates are less difficult then they seem. And the newer versions have an automatic update that makes it even easier.