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

Open handles after sending an APN notification #178

Open
Davies-Owen opened this issue Apr 15, 2022 · 2 comments
Open

Open handles after sending an APN notification #178

Davies-Owen opened this issue Apr 15, 2022 · 2 comments

Comments

@Davies-Owen
Copy link

Current behavior:

After sending a notification via APN, node will not exit due to open handles.

Expected behavior:

The process should exit normally after all tasks are complete.

Minimal reproduction:

Click to expand
const PushNotifications = require('node-pushnotifications');

const apn = {
  key: '<key>',
  keyId: '<keyId>',
  teamId: '<teamId>',
  topic: '<topic>',
};

async function main() {
  const push = new PushNotifications({
    apn: {
      production: false,
      token: {
        key: `-----BEGIN PRIVATE KEY-----\n${apn.key}\n-----END PRIVATE KEY-----`,
        keyId: apn.keyId,
        teamId: apn.teamId,
      },
    },
  });

  const pushData = {
    alert: {
      body: 'Test notification',
      title: 'Testing',
    },
    badge: undefined,
    body: 'Test notification',
    contentAvailable: true,
    custom: {
      sender: 'com.anybody.anywhere',
    },
    dryRun: false,
    expiry: 1652452374,
    priority: 'high',
    pushType: 'alert',
    retries: 1,
    silent: false,
    title: 'Testing',
    topic: apn.topic,
  };

  const devices = ['<iOS device token>'];
  console.log('Sending push notification...');
  const response = await push.send(devices, pushData);
  console.log(response);
}

main();

Open handles according to why-is-node-running:

# TCPWRAP
/Users/owen/Documents/airfordable/af-ohare/packages/af-services/node_modules/@parse/node-apn/lib/client.js:121 - const session = (this.session = http2.connect(

# TLSWRAP
/Users/owen/Documents/airfordable/af-ohare/packages/af-services/node_modules/@parse/node-apn/lib/client.js:121 - const session = (this.session = http2.connect(

Thanks.

@alex-friedl
Copy link
Collaborator

Looks like it should be reported in the @parse/node-apn repo ?

@edwinw6
Copy link

edwinw6 commented Aug 10, 2023

I was just running into this issue. For future reference: the handles remain open until the APN provider is shutdown. This doesn't seem to happen automagically, but you can force it by calling push.setOptions({}) (replace push with your instance of PushNotifications).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants