liteflow-labs / starter-kit

NFT Marketplace running on the Liteflow infrastructure
https://demo.liteflow.com
Apache License 2.0
11 stars 43 forks source link

Referral creation error #261

Closed NicolasMahe closed 1 year ago

NicolasMahe commented 1 year ago

When navigating to my profile page (eg: https://localhost:3000/users/0x5e7760acf5d659278747b95da2ab2b5ea7171615) on a platform with the referral option activated, I get the following error the first time I load this page on fresh database:

duplicate key value violates unique constraint "Invitation_invitedByAddress_key": {"response":{"errors":[{"errcode":"23505","extensions":{"exception":{"errcode":"23505"}},"message":"duplicate key value violates unique constraint \"Invitation_invitedByAddress_key\"","locations":[{"line":2,"column":3}],"path":["createInvitation"]}],"data":{"createInvitation":null},"status":200,"headers":{"map":{"cache-control":"private","content-type":"application/json; charset=utf-8"}}},"request":{"query":"mutation CreateInvitation {\n createInvitation(input: {}) {\n invitation {\n id\n }\n }\n}"}}

Even with this error, the referral link is correctly display.

I think the creation of the invitation is done twice, once server-side, and one client side. We should deactivate this invitation creation from the SSR as the component is already doing a client side fetch of this invitation

antho1404 commented 1 year ago

SSR is not the reason for the error, as useEffect are not executed in the SSR, we do have this useEffect call twice, which seems to be related to the signer that is recreated even if the payload is the same

NicolasMahe commented 1 year ago

fixed in https://github.com/liteflow-labs/starter-kit/pull/263