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

Possible Race Condition when catching native events #47

Open
justin0mcateer opened this issue Mar 15, 2024 · 1 comment
Open

Possible Race Condition when catching native events #47

justin0mcateer opened this issue Mar 15, 2024 · 1 comment

Comments

@justin0mcateer
Copy link

We are using a networking library (libp2p) which has a transitive dependency on pEvent. We have identified a race condition where pEvent misses the 'open' event emitted by a DataChannel. The code in pEvent appears to synchronously build up a set of Promises to implement it's functionality, so it appears this race condition would not be possible. However, I wonder if because the 'open' event is being emitted by native code, the event can in fact be raised while pEvent is setting up its event handler.

We have a reproducible problem, with a functioning workaround, so we have a pretty high level of confidence that this is what is happening. I don't have anyway to verify, but it seems that this issue could also occur with any other 'native' events, such as DOM events, etc.

The details on the issue are captured in this issue on the downstream library:
libp2p/js-libp2p#2443

@sindresorhus
Copy link
Owner

There's really nothing this package can (or should) do if the native add-on does not adhere to JavaScript semantics (single-threadedness).

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