From 7fba53b3d856c8437bbbea2a98cb2b9d67251cc0 Mon Sep 17 00:00:00 2001 From: ZayanKhan-12 <108294002+ZayanKhan-12@users.noreply.github.com> Date: Mon, 3 Aug 2026 20:32:22 -0400 Subject: [PATCH 1/2] fix: ignore legacy publicConfig stream in createExternalExtensionProvider The MetaMask extension still writes state updates to the legacy `publicConfig` substream of its multiplexed connection. The provider created by `createExternalExtensionProvider` never registers a substream for it, so every message triggers an 'ObjectMultiplex - orphaned data for stream "publicConfig"' warning in the consuming extension's console. The MetaMask extension's own contentscript already handles this by calling `ignoreStream` on its multiplexer for the legacy stream name, so pages using the injected provider never see the warning. Apply the same pattern to the external extension provider path: register the `publicConfig` substream as ignored on the `ObjectMultiplex` instance before wiring up the pipeline. Fixes #294 Co-Authored-By: Claude Fable 5 --- .../createExternalExtensionProvider.test.ts | 17 +++++++++++++++++ .../createExternalExtensionProvider.ts | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/extension-provider/createExternalExtensionProvider.test.ts b/src/extension-provider/createExternalExtensionProvider.test.ts index 55906558..bf873916 100644 --- a/src/extension-provider/createExternalExtensionProvider.test.ts +++ b/src/extension-provider/createExternalExtensionProvider.test.ts @@ -157,6 +157,23 @@ describe('createExternalExtensionProvider', () => { expect(global.chrome.runtime.connect).toHaveBeenCalledWith('foobar'); }); + it('ignores messages for the legacy publicConfig stream', async () => { + const consoleWarnSpy = jest.spyOn(globalThis.console, 'warn'); + const { port } = await getInitializedProvider(); + + port.notify('publicConfig', { + jsonrpc: '2.0', + method: 'metamask_chainChanged', + params: { chainId: '0x1', networkVersion: '1' }, + }); + // Wait for the message to propagate through the stream pipeline. + await new Promise((resolve) => setTimeout(resolve, 10)); + + expect(consoleWarnSpy).not.toHaveBeenCalledWith( + 'ObjectMultiplex - orphaned data for stream "publicConfig"', + ); + }); + describe('RPC warnings', () => { const warnings = [ { diff --git a/src/extension-provider/createExternalExtensionProvider.ts b/src/extension-provider/createExternalExtensionProvider.ts index 5d545b53..3374b4a7 100644 --- a/src/extension-provider/createExternalExtensionProvider.ts +++ b/src/extension-provider/createExternalExtensionProvider.ts @@ -11,6 +11,12 @@ import { getDefaultExternalMiddleware } from '../utils'; const browser = detect(); +/** + * The name of the legacy public config substream. The MetaMask extension + * still writes to this stream, but the provider no longer uses it. + */ +const LegacyPublicConfigStreamName = 'publicConfig'; + export type ExtensionType = 'stable' | 'flask' | 'beta' | string; /** @@ -32,6 +38,10 @@ export function createExternalExtensionProvider( const pluginStream = new PortStream(metamaskPort); const streamName = MetaMaskInpageProviderStreamName; const mux = new ObjectMultiplex(); + // The wallet still writes to the legacy `publicConfig` stream. Ignore it + // to avoid "ObjectMultiplex - orphaned data" warnings, mirroring how the + // MetaMask extension contentscript ignores legacy streams. + mux.ignoreStream(LegacyPublicConfigStreamName); pipeline(pluginStream, mux, pluginStream, (error: Error | null) => { let warningMsg = `Lost connection to "${streamName}".`; if (error?.stack) { From 23a05e89f5e187ad5013e77687f8431ae46b1d8a Mon Sep 17 00:00:00 2001 From: ZayanKhan-12 <108294002+ZayanKhan-12@users.noreply.github.com> Date: Mon, 3 Aug 2026 20:32:53 -0400 Subject: [PATCH 2/2] docs: add changelog entry Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e675f10a..40a6c231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Ignore legacy `publicConfig` stream in `createExternalExtensionProvider` to prevent `ObjectMultiplex - orphaned data for stream "publicConfig"` warnings ([#429](https://github.com/MetaMask/providers/pull/429)) + ## [22.1.1] ### Changed