webext-bridge icon indicating copy to clipboard operation
webext-bridge copied to clipboard

`tabId` is null when `stream.send` from background script

Open hinryd opened this issue 1 year ago • 0 comments

Version

6.0.1

Current Behavior

When a stream is started by the content script, the tabId information in the endpoint data seems to get lost when it reaches the background script. Consequently, when attempting to send a message back to the content script using stream.send(), a TypeError is thrown.

I attempted a potential fix based on issue #66, which involved commenting out two specific lines of code. However, this resulted in an infinite loop in the aboutIncomingMessage function.

I'm not entirely familiar with the downstream logic, so any assistance in resolving this issue would be greatly appreciated.

Expected Behavior

stream.send() should send the message successfully

Steps To Reproduce

// content-script
const stream = openStream('test-channel', 'background')
// background
onOpenStreamChannel('test-channel', (stream) => {
  stream.onMessage((data) => {
    stream.send(data)
  })
})

Anything else?

No response

hinryd avatar Mar 01 '24 13:03 hinryd