From d9a0d134794e45203de99249e877714d7302a0f9 Mon Sep 17 00:00:00 2001 From: mahmed2000 Date: Sat, 30 Nov 2024 22:38:00 +0000 Subject: [PATCH] Communicate and handle apub outgoing updates being delayed (#4009) * Allow icon only status messages such as STATUS_PROCESSING to be displayed * Add a processing status state for the EditSocialLinks component * Log warning for the outbound apub channel being full * Buffer the outbound apub channel so some API requests are less likely to get blocked during handling * Make the apub outbound request trace-log always occur after being queued. * Linting fix --- activitypub/workerpool/outbound.go | 9 +++++++-- web/components/admin/FormStatusIndicator.tsx | 2 +- .../admin/config/general/EditSocialLinks.tsx | 12 +++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/activitypub/workerpool/outbound.go b/activitypub/workerpool/outbound.go index a3d0fadea..8d8f347f5 100644 --- a/activitypub/workerpool/outbound.go +++ b/activitypub/workerpool/outbound.go @@ -19,7 +19,7 @@ var queue chan Job // InitOutboundWorkerPool starts n go routines that await ActivityPub jobs. func InitOutboundWorkerPool() { - queue = make(chan Job) + queue = make(chan Job, workerPoolSize*5) // arbitrary buffer value. // start workers for i := 1; i <= workerPoolSize; i++ { @@ -29,8 +29,13 @@ func InitOutboundWorkerPool() { // AddToOutboundQueue will queue up an outbound http request. func AddToOutboundQueue(req *http.Request) { + select { + case queue <- Job{req}: + default: + log.Warnln("Outbound ActivityPub job queue is full") + queue <- Job{req} // will block until received by a worker at this point + } log.Tracef("Queued request for ActivityPub destination %s", req.RequestURI) - queue <- Job{req} } func worker(workerID int, queue <-chan Job) { diff --git a/web/components/admin/FormStatusIndicator.tsx b/web/components/admin/FormStatusIndicator.tsx index 08d8cd5b5..29a7c67eb 100644 --- a/web/components/admin/FormStatusIndicator.tsx +++ b/web/components/admin/FormStatusIndicator.tsx @@ -12,7 +12,7 @@ export const FormStatusIndicator: FC = ({ status }) => const classes = classNames({ 'status-container': true, [`status-${type}`]: type, - empty: !message, + empty: !message && !icon, }); return ( diff --git a/web/components/admin/config/general/EditSocialLinks.tsx b/web/components/admin/config/general/EditSocialLinks.tsx index d7ee0a49e..fb1fd22e2 100644 --- a/web/components/admin/config/general/EditSocialLinks.tsx +++ b/web/components/admin/config/general/EditSocialLinks.tsx @@ -19,7 +19,12 @@ import { DEFAULT_TEXTFIELD_URL_PATTERN, } from '../../../../utils/validators'; import { TextField } from '../../TextField'; -import { createInputStatus, STATUS_ERROR, STATUS_SUCCESS } from '../../../../utils/input-statuses'; +import { + createInputStatus, + STATUS_ERROR, + STATUS_PROCESSING, + STATUS_SUCCESS, +} from '../../../../utils/input-statuses'; import { FormStatusIndicator } from '../../FormStatusIndicator'; const { Title } = Typography; @@ -140,6 +145,11 @@ export default function EditSocialLinks() { // posts all the variants at once as an array obj const postUpdateToAPI = async (postValue: any) => { + if (!displayModal) { + // only create the processing status if the modal is inactive + resetTimer = null; + setSubmitStatus(createInputStatus(STATUS_PROCESSING)); + } await postConfigUpdateToAPI({ apiPath: API_SOCIAL_HANDLES, data: { value: postValue },