response.data.onlineToken doesn't exist
Summary
Error is thrown due to attempt to access property of undefined. The corresponding catch block suppresses the error. Because the execution moves to the catch block, setAuthenticationInformation()
isn't called.
Which version and OS are you using?
macOS, recent next
How to reproduce the bug?
- In
setAuthenticationInformation()
, add a console.log to verify it isn't called. - In the catch block, add a console.log to verify that an error is thrown.
- Submit a change in user profile modal, e.g. language.
- Observe in the console that an access property of undefined error was thrown and that
setAuthenticationInformation()
isn't called.
What's the actual bug behavior?
- An attempt to access property
data.onlineToken
inresponse
was made, however it doesn't exist. As such, that error was thrown. - The actual shape of
response
is:
{
"code": 200,
"message": {
"code": "USER_EDITED",
"data": {}
}
}
- Because execution had moved to the catch block,
setAuthenticationInformation()
isn't called. - Because
setAuthenticationInformation()
isn't called,setSettings()
isn't called. - Because
setSettings()
isn't called, the settings store is stale. - This blocks #1505 (closed) because its solution relies on an up-to-date store.
What should happen instead?
setAuthenticationInformation()
should run.
Some ideas to make this happen are:
- Move
setAuthenticationInformation()
tofinally
- Not do
data.onlineToken = response.data.onlineToken
- Have
data.onlineToken
in the response
Logs and/or screenshots
N/A
Edited by Alex Tan