Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wait-on dependency #495

Closed
wants to merge 1 commit into from

Conversation

felabr
Copy link

@felabr felabr commented Dec 21, 2023

Update the wait-on dependency to ^7.2.0.
Earlier versions use an older version of axios with a security issue.
This should solve #493

@felabr
Copy link
Author

felabr commented Dec 22, 2023

Hi @oblador, not sure how things proceed from here on ... could you have a look at this tiny PR?

@gatsbimantico
Copy link

Hello @felabr I was aiming to propose the same update.

I think loki is still a commonjs project, while wait-on or axios have moved into ESM and that's making your test fail.

In loki/packages/target-chrome-docker/src/create-chrome-docker-target.js it will need to use a dynamic import, instead of require to import wait-on. Luckily for us it's already used within a promise, so the asyncronous nature of the dynamic import shouldn't affect anything else.

Instead of

waitOn = require('wait-on');

Promise(...
  waitOn(...)

needs to be something like

Promise(...
  import('wait-on').then(module => module.default).then(waitOn => waitOn(...))

From the docs: https://nodejs.org/api/esm.html#import-expressions

Dynamic import() is supported in both CommonJS and ES modules. In CommonJS modules it can be used to load ES modules.

Let me know your thoughts.

@felabr
Copy link
Author

felabr commented Jan 16, 2024

Yes, that would be great!
I tried a lot, Promises and async/await, but didn't get it to work (yet). Whenever there's a dynamic import for wait-on it keeps running for ever. It even stops working when I just add this line:

import('wait-on').then((module) => console.log(module));

and change the test command in package.json like so:

"test": "yarn node --experimental-vm-modules $(yarn bin jest)",

The leanest thing I came up with (in my own opinion) is this:

const waitOnCDPAvailable = async (host, port) => {
  const { default: waitOn } = await import('wait-on');
  await waitOn({.....});
};

Anyway, if anybody has an idea how to make the wait-on ESM and the dynamic import work here, please let me know.

@flieks
Copy link

flieks commented Jan 25, 2024

I also get this problem with loki and people that install our npm package are getting the vulnerability warning for that reason. Would be great if this can be fixed

@oblador
Copy link
Owner

oblador commented Jan 25, 2024

Fixed in 0.34.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants