most-nightfall-36645
09/21/2022, 4:03 PMCould not fetch logged in user from cache. + Unexpected token < in JSON at position 0
Has anyone else experience this?
I checked the gms and react containers, neither are reporting any error logs. I also check elastic search, kafka and our mysql database, non are under contention and maintain reasonable response and read/write latencies.useGetAuthenticatedUser.tsx
/**
* Fetch a CorpUser object corresponding to the currently authenticated user.
*/
export function useGetAuthenticatedUser(skip?: boolean) {
const userUrn = Cookies.get(CLIENT_AUTH_COOKIE);
if (!userUrn) {
throw new Error('Could not find logged in user.');
}
const { data, error } = useGetMeQuery({ skip, fetchPolicy: 'cache-and-network' });
if (error) {
console.error(`Could not fetch logged in user from cache. + ${error.message}`);
}
return data?.me;
}
/**
* Fetch an urn corresponding to the authenticated user.
*/
export function useGetAuthenticatedUserUrn() {
const userUrn = Cookies.get(CLIENT_AUTH_COOKIE); // <---- This is the error
if (!userUrn) {
throw new Error('Could not find logged in user.');
}
return userUrn;
}
according to `assets/static/js/conf/Global.ts`:
/**
* Name of the auth cookie checked on client side (contains the currently authenticated user urn).
*/
export const CLIENT_AUTH_COOKIE = 'actor';
My actor
cookie value:
actor = "urn:li:corpuser:my_email@address.com"
So am confused by that error -- seems datahub is using this cookie library:
function get (name) {
if (typeof document === 'undefined' || (arguments.length && !name)) {
return
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all.
var cookies = document.cookie ? document.cookie.split('; ') : []
var jar = {}
for (var i = 0; i < cookies.length; i++) {
var parts = cookies[i].split('=')
var value = parts.slice(1).join('=')
try {
var found = decodeURIComponent(parts[0])
jar[found] = converter.read(value, found)
if (name === found) {
break
}
} catch (e) {}
}
return name ? jar[name] : jar
}
I cant see why this code would read the html tag from the 'dom' and parse the html tags.
Specifically the only read of the dom is:
var cookies = document.cookie ? document.cookie.split('; ') : []