Skip to content

Open handles after sending an APN notification  #178

@Davies-Owen

Description

@Davies-Owen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions