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

Is it possible to send multiple push requests using the same template instance in parallel? #454

Open
guisehn opened this issue Jun 2, 2020 · 1 comment

Comments

@guisehn
Copy link

guisehn commented Jun 2, 2020

I was looking the Template.push definition and noticed that it uses an apn variable on the instance and there's some sort of lifecycle management for creating and destroying it.

I'm wondering if the way that it was implemented takes multiple parallel calls in consideration without causing any side-effect by overwriting the apn property.

e.g. is the code below supported?

const { Template } = require('@walletpass/pass-js')

// [...]

this.template = await Template.load(config)
const pushTokens = await getPushTokensFromSomewhere()
const sendPushPromises = pushTokens.map(token => this.template.pushUpdates(token))
await Promise.allSettled(sendPushPromises)
@guisehn guisehn changed the title Is it possible to send multiple push requests using the same template in parallel? Is it possible to send multiple push requests using the same template instance in parallel? Jun 2, 2020
@tinovyatkin
Copy link
Owner

Well, remember that Node is single-threaded, so, even in the race condition scenario, the worst case is that some other APN will be opened then auto closed.

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

2 participants