PharmaLedger-IMI / ctr-workspace

UC8 Clinical Trials Recruitment
MIT License
2 stars 0 forks source link

v0.6.5 TypeError: JSON.stringify cannot serialize cyclic structures wizard.js line 2008 / column 53 #32

Closed joaoluis-pdm closed 3 years ago

joaoluis-pdm commented 3 years ago

Enviado: 12 de agosto de 2021 22:09 ...

Thank you so much! I tested and it is working fine.

One issue I encountered, details are below.

One match request completed. 
I am trying to create a second match request for the same patient
    But before creating that, I clicked on “Health Info” and then clicked on “Find a Trial”.
    Encountered the below issue and was not able to submit the Match Request.

Hope you see the screenshot this time. If not the error says “TypeError : Json strngify cannot serialize cyclic structure”

joaoluis-pdm commented 3 years ago
...
const { GHI, TRIAL_PREFS, CONDITION, TRIAL } = require('../formDefs');
...
class MatchRequest extends Validatable{

...
    /**
     * 
     * @param {object} ghi an LForm for general health information.
     */
    constructor(ghi) {
        super();
        this.id = '_' + Math.random().toString(36);
        // deep clone ghi
        if (ghi) 
            this.ghiForm = JSON.parse(JSON.stringify(ghi));
        else
            this.ghiForm = JSON.parse(JSON.stringify(GHI)); <------- line 2008
    }

Hypotesis: Somehow, the GHI constant was used for an LForm without deep clone before, and became corrupted.

How to reproduce: 1 - register a new user 2 - click General Health information, and do not UPDATE (save) anything. 3 - click "FIND A TRIAL", and the error of this issue will occur.