MetaMask / MetaMask/providers

Provider emits warning: ObjectMultiplex - orphaned data for stream "publicConfig"

Open
#294 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
268
Forks
130
PR merge metrics
No merged PRs in 30d

Description

I'm using `createExternalExtensionProvider()` to create a Provider to interact with MetaMask from another browser extension. This works well, but a side-effect is that a lot of warnings are logged to the console:

> ObjectMultiplex - orphaned data for stream "publicConfig"

I looked into this, and my understanding is as follows:

- The communication streams between the in page/extension provider and MetaMask itself multiplex multiple named streams over a single connection using `ObjectMultiplex` from @metamask/object-multiplex
- The warning occurs when an `ObjectMultiplex` stream receives a message for a named substream that has not been created, so such messages will be ignored.
- The MetaMask extension itself is sending messages to the Provider I create for the `publicConfig` named substream
- I can see such messages being received **from** the `Port` opened to communicate with MetaMask from my extension
- It's not that some legacy thing in my extension is using the `publicConfig` stream.
- MetaMask's own injected contentscript ignores messages for the `publicConfig` substream, so web pages using MetaMask's provider don't show these warnings: https://github.com/MetaMask/metamask-extension/blob/c40dbb1ec72b91827debb2fffba4097a838f21c7/app/scripts/contentscript.js#L254
- The `StreamProvider` in this repo that creates the ObjectMultiplex *doesn't* ignore `publicConfig` messages: https://github.com/MetaMask/providers/blob/126a8c868785eb088511769cd532a72072662369/src/StreamProvider.ts#L70

Should `StreamProvider` ignore these messages itself, like MetaMask's contentscript does? I was tempted to open a PR to do this, but I don't have enough understanding of the legacy context around these messages to know if that makes sense.

It's not currently possible to customise the stream created by `createExternalExtensionProvider()` to filter these messages before they get to `StreamProvider`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/StreamProvider.ts around line 70 and compare its ObjectMultiplex handling with the referenced MetaMask contentscript behavior. Trace createExternalExtensionProvider() and the publicConfig messages to determine whether StreamProvider should ignore them. Done means the warning behavior is resolved consistently without breaking other named streams, with validation covering the affected provider path.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.