From 29456a24d50d8cea8e4e1b4cc4dfa1ab79e5057c Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Wed, 29 Jul 2026 15:49:01 -0700 Subject: [PATCH] emit Error objects from socket 'error' events main tightened the socket error contract to pass an Error (see types/modules/networking.d.ts, which documents the reason as `error.message`); the epoxy rewrite still emitted a bare string, matching the older `(reason: string)` declaration. Co-Authored-By: Claude Opus 5 (1M context) --- src/puter-js/src/modules/networking/PSocket.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/puter-js/src/modules/networking/PSocket.js b/src/puter-js/src/modules/networking/PSocket.js index 9beb5a9d6..b78b78986 100644 --- a/src/puter-js/src/modules/networking/PSocket.js +++ b/src/puter-js/src/modules/networking/PSocket.js @@ -19,12 +19,12 @@ function normalizeWriteData (data) { throw new Error('Invalid data type (not TypedArray, ArrayBuffer or String).'); } -function normalizeErrorReason (reason) { +function normalizeError (reason) { if ( reason instanceof Error ) { - return reason.message; + return reason; } - return String(reason); + return new Error(String(reason)); } export class PSocket extends EventListener { @@ -236,7 +236,7 @@ export class PSocket extends EventListener { return; } - this.emit('error', normalizeErrorReason(reason)); + this.emit('error', normalizeError(reason)); this.#closing = true; void this.#closeStreams(true); }