File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -315,14 +315,20 @@ function PhpbbWebpush() {
315315 if ( data . success ) {
316316 handleSubscribe ( data ) ;
317317 } else {
318- await newSubscription . unsubscribe ( ) ;
318+ // Server rejected the subscription; clean up the browser-side subscription
319+ // without awaiting, so a failure here can't bubble to the outer catch and
320+ // incorrectly trigger promptDenied or show the wrong error message.
321+ newSubscription . unsubscribe ( ) . catch ( console . error ) ;
319322 promptDenied . set ( ) ;
320323 hidePopup ( document . getElementById ( 'wpn_popup_prompt' ) ) ;
321324 phpbb . alert ( ajaxErrorTitle , data . message || subscribeButton . getAttribute ( 'data-l-unsupported' ) ) ;
322325 }
323326 } catch ( error ) {
324327 loadingIndicator . fadeOut ( phpbb . alertTime ) ;
325- phpbb . alert ( ajaxErrorTitle , error ) ;
328+ // Clean up the browser-side subscription so it doesn't become orphaned
329+ // when the server request fails (network error, bad JSON, etc.).
330+ newSubscription . unsubscribe ( ) . catch ( console . error ) ;
331+ phpbb . alert ( ajaxErrorTitle , error . message || subscribeButton . getAttribute ( 'data-l-unsupported' ) ) ;
326332 }
327333 } catch ( error ) {
328334 promptDenied . set ( ) ; // deny the prompt on error to prevent repeated prompting
You can’t perform that action at this time.
0 commit comments