fix(ipc): guard webChannelTransport.onmessage before invoking#83
Open
OcheOps wants to merge 1 commit into
Open
fix(ipc): guard webChannelTransport.onmessage before invoking#83OcheOps wants to merge 1 commit into
OcheOps wants to merge 1 commit into
Conversation
The preload script registered a message listener that unconditionally
calls window.qt.webChannelTransport.onmessage, but the transport shim
in this file only assigns .send. .onmessage is expected to be installed
later by the hosted web app.
When a message arrives from the shell before (or without) the web app
having assigned an .onmessage handler, the listener throws
'TypeError: undefined is not a function', which the Rust side surfaces
as:
ERROR stremio_linux_shell::app::webview:
Failed to send message: TypeError: undefined is not a function
Guarding the call with a typeof check makes the listener a no-op when
the transport is not yet ready, eliminating the spurious error without
changing behavior once the web app initializes.
Member
|
Hi, is this PR supposed to make this error message disappear? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The preload script (
src/app/ipc/preload.js) unconditionally callswindow.qt.webChannelTransport.onmessage(message)inside itsmessagelistener, but the transport shim in the same file only assigns.send..onmessageis expected to be installed later by the hosted stremio-web app.If a message arrives from the shell before (or without) the web app assigning
.onmessage, the listener throws:which the Rust side surfaces at startup as:
This is one of the errors reported in #68 / #73 / stremio-bugs#2646 and appears in every session on affected setups (Fedora 44 + AMD + GNOME/Wayland, but not limited to that combo — same log line appears in CachyOS + AMD reports).
Fix
Guard the call with a
typeofcheck. When the transport hasn't been fully initialized, the listener is now a no-op instead of throwing. Once stremio-web installs itsonmessagehandler, behavior is unchanged.window.ipc.addEventListener('message', (message) => { - window.qt.webChannelTransport.onmessage(message); + if (typeof window.qt.webChannelTransport.onmessage === 'function') { + window.qt.webChannelTransport.onmessage(message); + } });Notes
.onmessageis assigned:typeofcheck passes and the message is delivered as before.Refs #68, #73.