CodingGarden / listd

listd is a Full Stack App that will allow users to create, share and watch lists of YouTube channels. This app is being built LIVE on Twitch https://twitch.tv/codinggarden
https://twitch.tv/codinggarden
MIT License
191 stars 53 forks source link

Chores and fixes missing settings on user session #117

Closed Eckhardt-D closed 1 year ago

Eckhardt-D commented 1 year ago

What type of Pull Request is this?

Documentation updates to install playwright exe's for first timers and not overwrite .env.example.

What is the current behavior?

After setup and launching and signing up for the first time with my Google account, the settings were missing from the user object from the createUser event. I could replicate a few times, but required a DROP DATABASE. I could fix it by explicitly adding the created settings to the session user (perhaps there is a race condition?).

Another thought that might require an issue: what if the Prisma insert fails for the User settings?

Issue Number: N/A

What is the new behavior?

Other information

☀️

Eckhardt-D commented 1 year ago

@w3cj I made this a draft PR as I'm not entirely sure if the session fix is an actual fix. The assumption is that Authjs is returning the same user that is being passed to createUser when calling session(). After inspecting docker logs though it seems that it could also be an issue that occurred in the migrate:

listd-db-1     | 2023-04-29 05:05:28.394 UTC [81] ERROR:  insert or update on table "UserSettings" violates foreign key constraint "UserSettings_localeId_fkey"

I think the safest would be to wrap the userSettings create call in a trycatch since there could be database errors and this is required info on the session, breaking the app for the user until a manual create is run again. If the create throws, you could revert the user insert? Or stop the account creation in linkAccount event. 🤔