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

Are Promises supported (asynchronous callbacks)? #248

Open
pkrukp opened this issue Jul 19, 2020 · 2 comments
Open

Are Promises supported (asynchronous callbacks)? #248

pkrukp opened this issue Jul 19, 2020 · 2 comments

Comments

@pkrukp
Copy link

pkrukp commented Jul 19, 2020

Hi,

I'm trying to figure out if I can do sax.createStream().on("opentag", async (node) => { ... - will sax wait for Promise returned by the callback?

I searched code on github for "Promise", "then", "catch" but found nothing, so I suppose it won't?

@dobromyslov
Copy link

Yes. But if your async callback has nested promises and awaits for them then you will struggle Events-vs-Promises execution order because sax-js will not pause generation of new events. And there is no pause method to stop events. Even readable stream pause method will not help to achieve synchronous processing.

@dobromyslov
Copy link

@pkruk2 have a look at this solution: lddubeau/saxes#32 (comment)

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