AudioPlayerLite: fix 'originalComponent is not a function' on the second scene opened - #754
Merged
DogmaDragon merged 1 commit intoAug 11, 2026
Conversation
The patch was registered inside the stash:location handler, so every navigation to a scene pushed another copy onto insteadFns["ScenePlayer"]. With more than one patch in the chain, runInstead() passes the next patch as an extra trailing argument, so the second copy receives the original component as its second argument and reads undefined as the third one, failing with "TypeError: originalComponent is not a function". Only the first scene opened after a page load worked; every later one errored out until the page was reloaded. Register the patch once, and render the original component through React.createElement instead of calling it with a single argument, so the patch chain keeps working if another plugin patches ScenePlayer too. Also call setStyle() instead of the undefined poster(), and guard against scenes with no files.
Contributor
Author
|
Tested in the browser on my own instance: opened several scenes back to back without reloading the page — the error no longer occurs and the player behaves as before. Previously the second scene opened after a page load failed every time. |
|
This pull request has been mentioned on Stash Forum. There might be relevant details there: |
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.
The bug
Opening a scene works right after a page load, but every scene opened afterwards (without reloading) fails with the generic "Something went wrong." page:
Reloading the page makes it work again — once.
Cause
The plugin registers its patch inside the
stash:locationhandler, so every navigation to/scenes/<id>pushes another copy of the same function ontoinsteadFns["ScenePlayer"]—patch.instead()only appends, it never deduplicates.Once there is more than one patch in the chain,
runInstead()(ui/v2.5/src/patch.tsx) hands each patch the next one as a trailing argument:React calls a function component as
(props, secondArg), which is why the first patch correctly receives the original as its third argument. But the plugin invokes it asoriginalComponent({ ...props, scene })— a single argument — so the proxy passes(props, next)to the second copy. There the original component lands in the second parameter and the third one isundefined, henceoriginalComponent is not a function, thrown from the proxy'sapplytrap.The fix
React.createElement(originalComponent, ...)instead of calling it with one argument, so the chain still works if another plugin patchesScenePlayeras well.setStyle()instead ofposter(), which is not defined anywhere in the file and would throw aReferenceErroras soon as an actual audio file was opened.props.scene.files[0]against scenes with no files.Testing
The patched file is deployed on my own instance, where this error was breaking scene playback regularly.
node ./validate.js --cipasses.Disclosure
The patch was drafted with LLM assistance; I reviewed it and tested it on my own instance, and I take responsibility for the code.