From d415ffc6c721675035028746526152a2d088d3cf Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Fri, 14 Jun 2024 12:01:55 +0100 Subject: [PATCH] bugfix for incorrect notification handling --- .../src/createStreamMiddleware.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/json-rpc-middleware-stream/src/createStreamMiddleware.ts b/packages/json-rpc-middleware-stream/src/createStreamMiddleware.ts index 617e4ba0a1..3cbf8a048e 100644 --- a/packages/json-rpc-middleware-stream/src/createStreamMiddleware.ts +++ b/packages/json-rpc-middleware-stream/src/createStreamMiddleware.ts @@ -4,11 +4,12 @@ import type { JsonRpcMiddleware, } from '@metamask/json-rpc-engine'; import SafeEventEmitter from '@metamask/safe-event-emitter'; -import type { - JsonRpcNotification, - JsonRpcParams, - JsonRpcRequest, - PendingJsonRpcResponse, +import { + hasProperty, + type JsonRpcNotification, + type JsonRpcParams, + type JsonRpcRequest, + type PendingJsonRpcResponse, } from '@metamask/utils'; import { Duplex } from 'readable-stream'; @@ -85,7 +86,7 @@ export default function createStreamMiddleware(options: Options = {}) { ) { let errorObj: Error | null = null; try { - const isNotification = !res.id; + const isNotification = !hasProperty(res, 'id'); if (isNotification) { processNotification(res as unknown as JsonRpcNotification); } else {