question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to destroy peer object

See original GitHub issue

I have a peer object defined as var peer = new Peer()

Calling peer.destroy() leads to the error:

ReferenceError: process is not defined at emitReadable (_stream_readable.js:529) at onEofChunk (_stream_readable.js:506) at readableAddChunk (_stream_readable.js:255) at Peer.push…/node_modules/simple-peer/node_modules/readable-stream/lib/_stream_readable.js.Readable.push (_stream_readable.js:241) at Peer._destroy (index.js:408) at Peer.destroy (index.js:398) at Socket.<anonymous> (sender.component.ts:88) at Socket.push…/node_modules/ngx-socket-io/node_modules/component-emitter/index.js.Emitter.emit (index.js:133) at Socket.push…/node_modules/ngx-socket-io/node_modules/socket.io-client/lib/socket.js.Socket.onevent (socket.js:278) at Socket.push…/node_modules/ngx-socket-io/node_modules/socket.io-client/lib/socket.js.Socket.onpacket (socket.js:23).

What I’m trying to achieve is if a remote client refreshes the browser, I want all other clients to destroy the connection to that remote client.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:11

github_iconTop GitHub Comments

3reactions
izakglcommented, Apr 17, 2020

For simple-peer to work correctly in angular you need some polyfills. Add this to your polyfills.ts file:

import * as process from 'process';

(window as any).global = window;
(window as any).process = process;
(window as any).Buffer = [];

And install this package: https://www.npmjs.com/package/process

2reactions
janesenaj42commented, Apr 21, 2020

It works! Thank you.

For simple-peer to work correctly in angular you need some polyfills. Add this to your polyfills.ts file:

import * as process from 'process';

(window as any).global = window;
(window as any).process = process;
(window as any).Buffer = [];

And install this package: https://www.npmjs.com/package/process

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simple-peer. Cannot signal after peer is destroyed
Uncaught Error: cannot signal after peer is destroyed. I'm not destroying the peer in my code either end i.e. no peer.destroy() being called ......
Read more >
PeerJS Documentation
Attempt to reconnect to the server with the peer's old ID. Only disconnected peers can be reconnected. Destroyed peers cannot be reconnected. If...
Read more >
RTCPeerConnection: connectionstatechange event - Web APIs
For an RTCPeerConnection , pc , this example sets up a handler for connectionstatechange messages to handle changes to the connectivity of the ......
Read more >
simple-peer - npm
Destroy and cleanup this peer connection. If the optional err parameter is passed, then it will be emitted as an 'error' event on...
Read more >
Errors | Node.js v19.3.0 Documentation
Error objects capture a "stack trace" detailing the point in the code at which the ... was destroyed before any data was transmitted...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found