Skip to content

Creating peer without network connection crashes an app #6

@VladSalat666

Description

@VladSalat666

Hi

If there is no network connection, folowing code crashes an app:

let peer = peerJs(id, {
	host: 'example.com',
	port: 443,
	debug: 0,
	secure: true,
	pingInterval: 5000,
	config: {
		iceServers: [
			{ urls: ['stun:stun.l.example.com:1245'] },
			{ urls: ['turn:[email protected]:1234'], username: 'user', credential: 'root' }
		]
	}
});

Even trycatch can't handle this error...

events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND example.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
Emitted 'error' event on WebSocket instance at:
    at ClientRequest.<anonymous> (/Users/node_modules/ws/lib/websocket.js:554:15)
    at ClientRequest.emit (events.js:210:5)
    at TLSSocket.socketErrorListener (_http_client.js:406:9)
    at TLSSocket.emit (events.js:210:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'example.com'
}

host replaced by example.com, with right host and network connection all works good

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions