Experiment restarts for some participants

Hi, my Psychopy/Pavlovia experiment restarts for ~10-20% of my participants at the very end of the experiment when they are supposed to be redirected to another experiment, and despite being told that their data has saved, no datafile gets saved. Has anyone ever heard of such an issue? The closest relevant thread I could find is: Participants report that the experiment restarts at an unexpected time

I’m happy to share my builder file but here is the code snippet at the end. Basically, it redirects participants to lr_survey if they have completed parts 3 and 4 (order randomised per participant), but if only one part has been completed, they get redirected to the other part. In general this works quite easily, apart from the aforementioned issue which I was actually having myself before I added a short delay before the redirect in case participants were being redirected before the data was saved. But I don’t know why that would ever redirect to the start of the experiment again. :melting_face:

const url_for_other_half = “https://run.pavlovia.org/my_username/lr_exp4_loudness_ratings_words”;
const url_for_else = “https://run.pavlovia.org/my_username/lr_survey”;

// Get participant ID from expInfo (default to “000000” if missing)
const participantID = expInfo[“participant”] || “000000”;

// Only redirect if coming from exp3
if (expInfo[“from”] === “exp3”) {

// Build query string
const q = new URLSearchParams({
    participant: participantID,
    session: expInfo["session"] || "",
    from: "exp4",
    prolific_id: expInfo["prolific_id"],
    finalVolume: window.finalVolume || "" 
}).toString();

// Tiny delay to ensure CSV is saved
setTimeout(() => {
    window.location.href = `${url_for_other_half}?${q}`;
}, 2000);

// psychoJS.quit({message: “”, isCompleted: true})
// .then(() => {
// window.location.href = ${url_for_other_half}?${q};
// });

} else {

// Build query string
const q = new URLSearchParams({
    participant: participantID,
    session: expInfo["session"] || "",
    from: "exp4",
    prolific_id: expInfo["prolific_id"],
    finalVolume: window.finalVolume || "" 
}).toString();

setTimeout(() => {
    window.location.href = `${url_for_else}?${q}`;
}, 2000);

// psychoJS.quit({message: “”, isCompleted: true})
// .then(() => {
// window.location.href = ${url_for_else}?${q};
// });

}

This method for daisy chaining is unstable. Is there a reason why you are using it instead of the recommended method?