Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nightscout crashes after failed APNs delivery #8292

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build Docker Image
on:
push:
branches:
- upstream/wip/nspro/dev
jobs:
build:
name: push docker image to docker hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: login to docker hub
id: docker-hub
env:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_PASSWORD}}
run: |
docker login -u $username -p $password
- name: build the docker image
id: build-docker-image
run: |
ls -la
docker build . -f Dockerfile -t nightscoutpro/cgm-remote-monitor:dev
- name: push the docker image
id: push-docker-image
run: docker push ${{secrets.DOCKERHUB_USERNAME}}/cgm-remote-monitor:dev
28 changes: 25 additions & 3 deletions lib/server/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,36 @@ function init (env, ctx) {
notification.payload = payload;
notification.interruptionLevel = "time-sensitive"

provider.send(notification, [loopSettings.deviceToken]).then( (response) => {
provider.send(notification, [loopSettings.deviceToken]).then((response) => {
if (response.sent && response.sent.length > 0) {
completion();
} else {
console.log("APNs delivery failed:", response.failed)
completion("APNs delivery failed: " + response.failed[0].response.reason);
console.log("APNs delivery failed:", response.failed);

// Check if response.failed and response.failed[0] are defined
if (response.failed && response.failed.length > 0) {
const failedResponse = response.failed[0];
const reason = failedResponse.response && failedResponse.response.reason
? failedResponse.response.reason
: 'Unknown reason';

// Provide detailed debugging information
const errorMessage = `APNs delivery failed: ${reason}`;
console.error(errorMessage, failedResponse);
completion(errorMessage);
} else {
// Handle the case where response.failed is undefined or empty
const errorMessage = 'APNs delivery failed: No failure details available.';
console.error(errorMessage, response);
completion(errorMessage);
}
}
}).catch((error) => {
// Catch any other unexpected errors
console.error('Unexpected error during APNs delivery:', error);
completion(`APNs delivery failed: ${error.message || 'Unknown error'}`);
});

};

return loop();
Expand Down