DEV: Fix presence testing in legacy ember environment (#14596)
The legacy testing environment will remove the User.current() value before disposing of controllers/components. Presence often involves making HTTP calls during disposal of components, so this can cause issues. Production, and the modern Ember-CLI environment, do not require this hack, so it is behind an `isTesting() && isLegacyEmber()` check.
This commit is contained in:
parent
74706bab10
commit
bc68da24cd
|
@ -5,7 +5,7 @@ import { ajax } from "discourse/lib/ajax";
|
||||||
import { cancel, debounce, later, next, once, throttle } from "@ember/runloop";
|
import { cancel, debounce, later, next, once, throttle } from "@ember/runloop";
|
||||||
import Session from "discourse/models/session";
|
import Session from "discourse/models/session";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import { isTesting } from "discourse-common/config/environment";
|
import { isLegacyEmber, isTesting } from "discourse-common/config/environment";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
|
|
||||||
const PRESENCE_INTERVAL_S = 30;
|
const PRESENCE_INTERVAL_S = 30;
|
||||||
|
@ -464,8 +464,14 @@ export default class PresenceService extends Service {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Updating server failed. Put the failed events
|
if (e.jqXHR?.status === 403 && isTesting() && isLegacyEmber()) {
|
||||||
// back in the queue for next time
|
// Legacy testing environment will remove the User.current() value before disposing of controllers/components.
|
||||||
|
// Presence often involves making HTTP calls during disposal of components, so this can cause issues.
|
||||||
|
// Modern Ember-CLI environment does not require this hack
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put the failed events back in the queue for next time
|
||||||
this._queuedEvents.unshift(...queue);
|
this._queuedEvents.unshift(...queue);
|
||||||
if (e.jqXHR?.status === 429) {
|
if (e.jqXHR?.status === 429) {
|
||||||
// Rate limited. No need to raise, we'll try again later
|
// Rate limited. No need to raise, we'll try again later
|
||||||
|
|
Loading…
Reference in New Issue