diff --git a/src/core/Session.ts b/src/core/Session.ts index 555fe7ab..39f3f333 100644 --- a/src/core/Session.ts +++ b/src/core/Session.ts @@ -217,10 +217,17 @@ export default class Session extends EventEmitterLike { ) { let session_data: SessionData; + const session_args = { lang, location, time_zone: tz, device_category, client_name, enable_safety_mode, visitor_data }; + if (generate_session_locally) { - session_data = this.#generateSessionData({ lang, location, time_zone: tz, device_category, client_name, enable_safety_mode, visitor_data }); + session_data = this.#generateSessionData(session_args); } else { - session_data = await this.#retrieveSessionData({ lang, location, time_zone: tz, device_category, client_name, enable_safety_mode, visitor_data }, fetch); + try { + // This can fail if the data changes or the request is blocked for some reason. + session_data = await this.#retrieveSessionData(session_args, fetch); + } catch (err) { + session_data = this.#generateSessionData(session_args); + } } return { ...session_data, account_index };