mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-23 05:51:37 +00:00
refactor: examples-browser (#508)
* refactor: examples-browser * chore: add information to use signalling server * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com> * chore: update deps * docs: refactor libp2p browser example * docs(examples): add back websockets and boostrap nodes docs(examples): redo the browser readme * fix: handle edge case of connections closing early * chore: fix lint * chore: update example deps and readme * chore: update webrtc-star * chore: apply suggestions from code review Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai> Co-authored-by: Jacob Heun <jacobheun@gmail.com> Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
This commit is contained in:
@ -216,7 +216,10 @@ class Upgrader {
|
||||
Muxer,
|
||||
remotePeer
|
||||
}) {
|
||||
let muxer, newStream
|
||||
let muxer
|
||||
let newStream
|
||||
// eslint-disable-next-line prefer-const
|
||||
let connection
|
||||
|
||||
if (Muxer) {
|
||||
// Create the muxer
|
||||
@ -261,7 +264,7 @@ class Upgrader {
|
||||
const _timeline = maConn.timeline
|
||||
maConn.timeline = new Proxy(_timeline, {
|
||||
set: (...args) => {
|
||||
if (args[1] === 'close' && args[2] && !_timeline.close) {
|
||||
if (connection && args[1] === 'close' && args[2] && !_timeline.close) {
|
||||
connection.stat.status = 'closed'
|
||||
this.onConnectionEnd(connection)
|
||||
}
|
||||
@ -276,7 +279,7 @@ class Upgrader {
|
||||
}
|
||||
|
||||
// Create the connection
|
||||
const connection = new Connection({
|
||||
connection = new Connection({
|
||||
localAddr: maConn.localAddr,
|
||||
remoteAddr: maConn.remoteAddr,
|
||||
localPeer: this.localPeer,
|
||||
|
Reference in New Issue
Block a user