Linking anonymous credentials

By the concept when entering my app first time it automatically do login with anonymous credentials and as soon as user will decide to signup I want to merge existing credentials with newly added. But as soon as I’m trying to perform user.linkCredentials(...) or app.currentUser.linkCredentials(...) I’m getting invalid session: access token expired. There is no time limit how much user can be logged in anonymously, so probably that’s an issue, but I couldn’t find any mentions how I can update session or how to deal with such case. Any help would be appreciated. Thanks in advance!