bitfocus / companion

Bitfocus Companion enables the reasonably priced Elgato Streamdeck and other controllers to be a professional shotbox surface for an increasing amount of different presentation switchers, video playback software and broadcast equipment.
http://bitfocus.io/companion
Other
1.47k stars 489 forks source link

[BUG] 97a3f08 causes TypeError: Found non-callable @@iterator and Web UI to get stuck syncing #2756

Closed thedist closed 4 months ago

thedist commented 4 months ago

Is this a bug in companion itself or a module?

Is there an existing issue for this?

Describe the bug

97a3f08 has an issue with https://github.com/bitfocus/companion/blob/74e4074b4bc7d24bcc55bd05ada868270a09828a/companion/lib/UI/Handler.js#L123

Which results in the error

2024-02-19T13:29:02.498Z warn UI/Handler Error in client handler 'controls:subscribe:learn': TypeError: Found non-callable @@iterator TypeError: Found non-callable @@iterator
    at /companion/lib/UI/Handler.js:123:27
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

and similar for the other events like triggers:subscribe, surfaces:subscribe etc...

args is a function here, so trying to use the spread operator is what throws an error as you can't iterate over a function. Also, cb is undefined so even if line 123 was fixed, it'd error on 124 with cb is not a function, as that's also incorrect here.

Steps To Reproduce

  1. pull the latest commits
  2. run companion
  3. attempt to load the web ui, it'll remain syncing and Companion will give warnings in UI/Handler

Expected Behavior

Expected behaviour is that of prior to the commit.

Environment (please complete the following information)

- OS:Win 10
- Browser: Chrome 121.0.6167.185
- Companion Version: Latest main branch

Additional context

No response

Julusian commented 4 months ago

Did you rebuild the webui after pulling this change?

to go with this backend change, a change was made in the ui to adjust how the parameters are sent https://github.com/bitfocus/companion/blob/main/webui/src/util.tsx#L53-L62

This was all necessary to make typescript happy when defining the socket.io messages in typescript

thedist commented 4 months ago

Trying to build the webui gives me:

failed to load config from C:\Users\jeff\workspace\companion3\webui\vite.config.js
error during build:
TypeError: envCompatible.default is not a function
    at file:///C:/Users/jeff/workspace/companion3/webui/vite.config.js.timestamp-1708352277560-2c69c2db4c8ae.mjs:23:26
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Even if I change envCompatible.default, to envCompatible.default.default so that runs, it then errors on

RollupError: "useResizeObserver" is not exported by "node_modules/usehooks-ts/dist/esm/index.js", imported by "src/Buttons/ButtonGridActions.tsx".
file: C:/Users/jeff/workspace/companion3/webui/src/Buttons/ButtonGridActions.tsx:8:9
 6: import classnames from 'classnames'
 7: import { GenericConfirmModal, GenericConfirmModalRef } from '../Components/GenericConfirmModal.js'
 8: import { useResizeObserver } from 'usehooks-ts'
             ^
thedist commented 4 months ago

I did a fresh clone, yarn, and build, and this seems to be resolved now, so somehow my previous Companion clone must have ended up in an inconsistent state but I'm not sure how considering according to git pull and yarn both my previous clone and my new one were both up to date and should have been the same.

When I have time I'll have to compare the 2 and see what files ended up in an inconsistent state and why, but for now I'll close this.

Julusian commented 4 months ago

Possibly a stray node_modules folder? One of the recent changes was changing from mulitple isolated yarn1 projects to a yarn4 monorepo