You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, we are using this package through discordjs package and in some occasions (during high memory load) we can see this error in our logs:
Error: Unhandled 'error' event emitted, received [object Object]
at WebSocketShard.emit (/app/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:276:19)
at WebSocketShard.onError (/app/node_modules/@discordjs/ws/dist/index.js:1070:10)
at connection.onerror (/app/node_modules/@discordjs/ws/dist/index.js:683:12)
at callListener (/app/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onError (/app/node_modules/ws/lib/event-target.js:230:9)
at WebSocket.emit (node:events:519:28)
at emitErrorAndClose (/app/node_modules/ws/lib/websocket.js:1041:13)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
On file and line @vladfrangu/async_event_emitter/dist/index.cjs:276:19 there is this code:
consterr=newError(`Unhandled 'error' event emitted, received ${stringifiedError}`);
Which is part of this class method:
emit(eventName, ...args){letdoError=eventName==="error";constevents=this._events;if(events!==void0){doError=doError&&"error"inevents;}elseif(!doError){returnfalse;}if(doError){leter;if(args.length>0){er=args[0];}if(erinstanceofError){try{constcapture={};Error.captureStackTrace(capture,_AsyncEventEmitter.prototype.emit);Object.defineProperty(er,"stack",{value: enhanceStackTrace.call(this,er,capture),configurable: true});}catch{}thrower;}conststringifiedError=String(er);consterr=newError(`Unhandled 'error' event emitted, received ${stringifiedError}`);// <-- log message gets created hereerr.context=er;throwerr;}consthandlers=events[eventName];if(handlers===void0){returnfalse;}if(typeofhandlers==="function"){constresult=handlers.apply(this,args);if(result!==void0&&result!==null){handleMaybeAsync(this,result);}}else{constlen=handlers.length;constlisteners=arrayClone(handlers);for(leti=0;i<len;++i){constresult=listeners[i].apply(this,args);if(result!==void0&&result!==null){handleMaybeAsync(this,result);}}}returntrue;}
It looks like in cases when er variable is an object it gets incorrectly stringified into [object Object] which hides original error.
Maybe something like JSON.stringify(er) would be more suitable?
The text was updated successfully, but these errors were encountered:
Hi, we are using this package through
discordjs
package and in some occasions (during high memory load) we can see this error in our logs:On file and line
@vladfrangu/async_event_emitter/dist/index.cjs:276:19
there is this code:Which is part of this class method:
It looks like in cases when
er
variable is an object it gets incorrectly stringified into[object Object]
which hides original error.Maybe something like
JSON.stringify(er)
would be more suitable?The text was updated successfully, but these errors were encountered: