Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1345·peerjs

Peer.disconnected isn't reliable + Peer.connect doesn't wait for it

Author: stylehouseCreated Jul 22, 2025Updated Jun 29, 2026
Labelsbugunconfirmed

Please, check for existing issues to avoid duplicates.

  • No similar issues found.

What happened?

I want this app to autoconnect. I think I read somewhere that Peer.connect() will gracefully wait for PeerServer to connect, then complete... But this seems not to get to con.on'open' unless you wait for eer.on'open' before you Peer.connect(). Also, waiting for eer.on'open' by looking at eer.disconnected doesn't work as you'd expect. It isn't true when we begin.

See the three instances of eer.disconnected, two commented into the broken position in this commit:

https://github.com/stylehouse/jamsend/commit/e05236e6729849071a8f8f190a3e6c5546969c93

How can we reproduce the issue?

Run my app. Shouldn't this work, off the top of your head?

What do you expected to happen?

con.on'open' happens, automatically

Environment setup

  • OS: Ubuntu 24
  • Platform: { "name": "jamsend", "version": "0.0.1", "dependencies": { "@noble/ed25519": "^2.2.3", "@sveltejs/adapter-node": "^5.2.12", "@types/express": "^5.0.3", "express": "^5.1.0", "peerjs": "^1.5.5", "socket.io": "^4.8.1", "socket.io-client": "^4.8.1" }, "devDependencies": { "@sveltejs/adapter-auto": "^6.0.1", "@sveltejs/kit": "^2.21.0", "@sveltejs/vite-plugin-svelte": "^5.0.3", "@testing-library/jest-dom": "^6.6.3", "@testing-library/svelte": "^5.2.7", "jsdom": "^26.1.0", "svelte": "^5.28.6", "svelte-check": "^4.1.7", "svelte-copy-url-button": "^1.0.6", "svelte-qrcode": "^1.0.1", "typescript": "^5.8.3", "vite": "^6.3.5", "vitest": "^3.1.3" } }
  • Browser: Chromium 138.0.7204.100

Is this a regression?

No response

Anything else?

No response

Source: peers/peerjs

View original on GitHubView discussion on GitHub