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

fix: unhandled promise rejection when async work done after handshake #2

Merged

Conversation

achingbrain
Copy link
Collaborator

If you do async work after invoking it-handshake but before awaiting
on any of the fields of the response, an unhandledPromiseRejection can
occur if the stream.sink method rejects.

This manifests itself in libp2p vis multiformats/js-multistream-select
as:

(node:82951) UnhandledPromiseRejectionWarning: Error: already piped
    at Object.sink (node_modules/it-pair/index.js:10:24)
    at module.exports (node_modules/it-handshake/src/index.js:15:30)
    at module.exports (src/select.js:10:57)
    at Dialer.select (src/index.js:27:12)
    at Context.<anonymous> (test/dialer.spec.js:43:26)

Also:

  • Updates all deps
  • Removes node Buffers in favour of Uint8Arrays

If you do async work after invoking it-handshake but before awaiting
on any of the fields of the response, an unhandledPromiseRejection can
occur if the `stream.sink` method rejects.

This manifests itself in libp2p vis `multiformats/js-multistream-select`
as:

```js
(node:82951) UnhandledPromiseRejectionWarning: Error: already piped
    at Object.sink (node_modules/it-pair/index.js:10:24)
    at module.exports (node_modules/it-handshake/src/index.js:15:30)
    at module.exports (src/select.js:10:57)
    at Dialer.select (src/index.js:27:12)
    at Context.<anonymous> (test/dialer.spec.js:43:26)
```

Also:

- Updates all deps
- Removes node Buffers in favour of Uint8Arrays
@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2020

Codecov Report

Merging #2 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #2   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           17        21    +4     
=========================================
+ Hits            17        21    +4     
Impacted Files Coverage Δ
src/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88dd90f...5a76ea2. Read the comment docs.

@jacobheun jacobheun merged commit 61db942 into jacobheun:master Aug 12, 2020
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

Successfully merging this pull request may close these issues.

3 participants