From 758fb2d4ec75837a2c9c7abaf5cee113dad41c18 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 12 Dec 2025 20:42:08 +0100 Subject: [PATCH] Improve test script error handling for missing wrtc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Better error message when wrtc is not installed, with clear instructions on how to install it. 🤖 Generated with Claude Code https://claude.com/claude-code Co-Authored-By: Claude Sonnet 4.5 --- test-connect.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/test-connect.js b/test-connect.js index e3f6703..fecdd73 100644 --- a/test-connect.js +++ b/test-connect.js @@ -2,15 +2,32 @@ /** * Test script to connect to @bas's chat service and send a "hello" message * - * Usage: node test-connect.js + * Setup: + * npm install --save-optional wrtc * - * Requires Node.js 19+ or Node.js 18 with --experimental-global-webcrypto + * Usage: + * node test-connect.js + * + * Requires: + * - Node.js 19+ or Node.js 18 with --experimental-global-webcrypto + * - wrtc package (install with: npm install wrtc) */ import { Rondevu, RondevuSignaler, NodeCryptoAdapter } from '@xtr-dev/rondevu-client' -import wrtc from 'wrtc' -const { RTCPeerConnection } = wrtc +// Try to import wrtc, provide helpful error if not found +let RTCPeerConnection +try { + const wrtc = await import('wrtc') + RTCPeerConnection = wrtc.default.RTCPeerConnection +} catch (error) { + console.error('❌ Error: wrtc package not found') + console.error('\nThe wrtc package is required for WebRTC support in Node.js.') + console.error('Install it with:') + console.error('\n npm install wrtc') + console.error('\nNote: wrtc requires native compilation and may take a few minutes to install.') + process.exit(1) +} // Configuration const API_URL = 'https://rondevu.xtrdev.workers.dev'