Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

kurento-client-core: Cannot find module 'async' #624

Open
3 tasks done
joeflateau opened this issue May 4, 2022 · 5 comments
Open
3 tasks done

kurento-client-core: Cannot find module 'async' #624

joeflateau opened this issue May 4, 2022 · 5 comments
Labels
known-issues Known issues that users find frequently

Comments

@joeflateau
Copy link

Prerequisites

These are MANDATORY, otherwise the issue will be automatically closed.

Issue description

kurento-client depends on kurento-client-core which depends on the module async. However, since many modules may depend on async and very few others will depend on kurento-client-core you will often find yourself in a situation where async is installed in the kurent-client directory rather than your app's node_modules and kurento-client-core will not be able to import it properly.

node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'async'
Require stack:
- /var/my-app/node_modules/kurento-client-core/lib/abstracts/MediaElement.js
- /var/my-app/node_modules/kurento-client-core/lib/HubPort.js
- /var/my-app/node_modules/kurento-client-core/lib/index.js
- /var/my-app/node_modules/kurento-client/lib/KurentoClient.js
- /var/my-app/node_modules/kurento-client/lib/index.js
- /var/my-app/main.js

Context

How to reproduce?

Create a project and install both portfinder and kurento-client-core which require different versions of async. You will likely end up with a node_modules that looks like this:

my_app/node_modules/
  - kurento-client
    - async
  - kurento-client-core
  - portfinder
    - async

When kurento-client-core attempts to require("async") it will not be found.

Expected & current behavior

(Optional) Possible solution

kurento-client-core package.json should declare its dependency on async (or async should no longer be depended on)

Info about your environment

kurento-client: 6.16.0
npm: 8.8.0

About Kurento Media Server

About your Application Server

  • Programming Language: node
  • Kurento Client version: 6.16.0

About end-user clients

  • Device(s):
  • OS(es):
  • Browser(s):

Run these commands

cat /etc/lsb-release
kurento-media-server --version
dpkg -l | grep -Pi 'kurento|kms-|gst.*1.5|nice'
@github-actions
Copy link

github-actions bot commented May 4, 2022

Hello @joeflateau! 👋 we're sorry you found a bug... so first of all, thank you very much for reporting it.

To know about progress, check in Triage. All issues are considered Backlog Candidates until work priorities align and the issue is selected for development. It will then become part of our official Backlog.

@j1elo
Copy link
Member

j1elo commented May 5, 2022

kurento-client-core-js uses async in just one spot, here: https://github.com/Kurento/kurento-client-core-js/blob/7622ec2460c7c5c6c941d1c58ccd7d7ad8ef5543/lib/abstracts/MediaElement.js#L32

which later is only used exactly here: https://github.com/Kurento/kurento-client-core-js/blob/7622ec2460c7c5c6c941d1c58ccd7d7ad8ef5543/lib/abstracts/MediaElement.js#L493-L497

which raises the point, can we safely remove the usage of async and each in this module? (open question, I'm really not sure)

@joeflateau
Copy link
Author

async is one example but the real issue is that kurento-client-core doesn’t declare its dependencies and just expects to be able to use the dependencies of kurento-client. So I expect if the async module dependency is removed then another dependency will have the same issue.

@joeflateau
Copy link
Author

I tried looking through kurento-client-js and kms-core to see how the kurento-client-core package.json is generated to see about sending a PR to make sure the dependencies are preserved in the kurento-client-core but I wasn't able to decipher how that's actually generated.

@j1elo
Copy link
Member

j1elo commented May 5, 2022

I've been looking into it too, to reply here, here's the gist of it:

This model_package_json.ftl is the template used for all package.json files of all modules; both the ones part of Kurento, and any extra module that might be created by an user.

I agree that this template is lacking some kind of list that can be used by each module to specify their dependencies. Such list would be used by the template to inject them into the dependencies array in the resulting package.json... but having a look at it, seems nothing to that effect is present.

I guess that's why the original developers decided it was much easier to just add the dependencies to the JavaScript client library, instead of the specific internal components such as kurento-client-core-js.

@j1elo j1elo added the known-issues Known issues that users find frequently label Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
known-issues Known issues that users find frequently
Projects
None yet
Development

No branches or pull requests

2 participants