ably-js icon indicating copy to clipboard operation
ably-js copied to clipboard

Critical Dependency - got / keyv

Open andrewkouri opened this issue 2 years ago • 4 comments

Upon installing Ably with npm install I now receive the following errors on my logs:

Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/keyv/src/index.js
./node_modules/ably/node_modules/cacheable-request/src/index.js
./node_modules/ably/node_modules/got/dist/source/core/index.js
./node_modules/ably/node_modules/got/dist/source/create.js
./node_modules/ably/node_modules/got/dist/source/index.js
./node_modules/ably/build/ably-node.js
./node_modules/ably/promises.js
./app/api/create-token-request/route.ts

Some initial research led to the solution of "just closing my eyes" but for our project that is an unacceptable fix. How can I address this problem derived from the install of Ably?

I am using Next.js 13

┆Issue is synchronized with this Jira Task by Unito

andrewkouri avatar May 24 '23 19:05 andrewkouri

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3608

sync-by-unito[bot] avatar May 24 '23 19:05 sync-by-unito[bot]

Hey @starlight-akouri thanks for reporting this! Unfortunately this is not easy for us to fix right now - unless webpack/kv/cachable-request/got fix it on their end then the only thing we could do is migrate to an alternative nodejs http client.

I know the "close your eyes" comment isn't exactly reassuring but this isn't really a security issue or anything, it just means that some tools which trace modules might not be able to find all the dependencies of keyv. As long as ably-js is able to make an http request in your environment then there shouldn't be an issue.

There are a couple of suggested fixes in the keyv issue which might be worth trying if you'd like to get rid of the warning eg: https://github.com/jaredwray/keyv/issues/45#issuecomment-1079958339

owenpearson avatar May 26 '23 09:05 owenpearson

I received the same warning. I know it's not causing any errors, but it's super annoying.

image

hiramhuang avatar Jul 13 '23 22:07 hiramhuang

For those who wants to ignore the warning, you can refer to https://github.com/sindresorhus/got/issues/2267#issuecomment-1659768856

/** @type {import('next').NextConfig} */
const nextConfig = {
  // ...
  webpack: (config) => {
    // Ignore ALL webpack warnings produced by ./node_modules/keyv/src/index.js file
    config.ignoreWarnings = [
      { module: /node_modules\/keyv\/src\/index\.js/ },
    ];

    return config;
  },
};

module.exports = nextConfig;

hugo082 avatar Aug 01 '23 07:08 hugo082

Updating the suggested solution for this:

You should add the next line to your next.config.js file:

const nextConfig = {
  // ...
  experimental: {
    serverComponentsExternalPackages: ['ably'],
  },
};

You can read more about what is causing this in our README section and in next issue's comment: https://github.com/ably/ably-js/issues/1699#issuecomment-2022702584.

Closing this issue as this warning is not caused by Ably.

VeskeR avatar May 17 '24 12:05 VeskeR