Skip to content

fix: server crash when re-enabling push notifications#41341

Merged
dionisio-bot[bot] merged 3 commits into
developfrom
fix/push-enable-toggle-crash
Jul 13, 2026
Merged

fix: server crash when re-enabling push notifications#41341
dionisio-bot[bot] merged 3 commits into
developfrom
fix/push-enable-toggle-crash

Conversation

@KevLehman

@KevLehman KevLehman commented Jul 13, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Toggling the Push_enable setting off and back on crashed the server:

=== UnHandledPromiseRejection ===
Error: Configure should not be called more than once!
    at PushClass.configure (app/push/server/push.ts)
    at server/configuration/pushNotification.ts

The Push_enable settings watcher calls Push.configure() on every enable, but configure() throws by design when called twice. The throw inside the async watcher callback becomes an unhandled promise rejection, which crashes the process when EXIT_UNHANDLEDPROMISEREJECTION is set.

Push is now unconfigured when the setting is disabled: the APN connection is shut down (shutdownAPN()) and the isConfigured flag is reset, so re-enabling runs a clean configure() again. As a bonus, settings changed while push was disabled (certs, gateway) are picked up on re-enable, and no stale APN connection stays alive while push is disabled. The double-configure guard remains in place to catch genuine programming errors.

Issue(s)

Steps to test or reproduce

  1. As admin, enable Push > Enable (Push_enable)
  2. Disable it
  3. Enable it again
  4. Before: server logs UnHandledPromiseRejection: Configure should not be called more than once! (and exits when EXIT_UNHANDLEDPROMISEREJECTION is set). After: setting toggles cleanly, log line Push service disabled: shutting down existing connections appears on disable.

Further comments

Unit tests added for shutdownAPN in apn.spec.ts.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a server crash that could occur when push notifications were re-enabled after being disabled.
    • Push notification services now shut down cleanly when disabled.
    • Re-enabling push notifications now fully reapplies the latest push settings, including changes made while the feature was disabled.
    • Improved handling of shutdown errors to prevent service interruptions.

https://rocketchat.atlassian.net/browse/CORE-64

Re-enabling the Push_enable setting called Push.configure() a second
time, which throws by design and crashed the server via an unhandled
promise rejection in the settings watcher.

Push is now unconfigured when the setting is disabled (APN connection
shut down, configured flag reset), so re-enabling runs a clean
configure again.
@dionisio-bot

dionisio-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: preventing a server crash when push notifications are re-enabled.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b50984b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

A rejected shutdown promise behind void would itself become an
unhandled rejection. Await it wrapped in try/catch; connection
reference is still cleared synchronously.
@KevLehman KevLehman added this to the 8.7.0 milestone Jul 13, 2026
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.08%. Comparing base (ed594fd) to head (b50984b).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41341      +/-   ##
===========================================
- Coverage    69.11%   69.08%   -0.04%     
===========================================
  Files         3759     3759              
  Lines       147859   147885      +26     
  Branches     26420    26397      -23     
===========================================
- Hits        102196   102169      -27     
- Misses       41179    41228      +49     
- Partials      4484     4488       +4     
Flag Coverage Δ
unit 70.59% <88.88%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KevLehman

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@KevLehman KevLehman marked this pull request as ready for review July 13, 2026 18:11
@KevLehman KevLehman requested a review from a team as a code owner July 13, 2026 18:11
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Jul 13, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 13, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jul 13, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Re-trigger cubic

Merged via the queue into develop with commit 8ed0fa0 Jul 13, 2026
48 checks passed
@dionisio-bot dionisio-bot Bot deleted the fix/push-enable-toggle-crash branch July 13, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants