auth0 / node-jwks-rsa

A library to retrieve RSA public keys from a JWKS (JSON Web Key Set) endpoint.
MIT License
827 stars 233 forks source link

Dependency issue - lru-memoizer 'pseudomap' module not found #415

Open kieran-reportabl opened 1 month ago

kieran-reportabl commented 1 month ago

Checklist

Description

Versions

OS: Ubuntu 22.04.4 Node: 20.14.0, V8 11.3.244.8-node.23 jwks-rsa: 3.1.0

Compile time exception when starting an express.js node app:

2024-07-30T00:01:53.150192273Z Error: Cannot find module 'pseudomap'
2024-07-30T00:01:53.150195473Z Require stack:
2024-07-30T00:01:53.150198573Z - /home/site/wwwroot/node_modules/lru-memoizer/node_modules/lru-cache/lib/lru-cache.js
2024-07-30T00:01:53.150201973Z - /home/site/wwwroot/node_modules/lru-memoizer/lib/async.js
2024-07-30T00:01:53.150204973Z - /home/site/wwwroot/node_modules/lru-memoizer/lib/index.js
2024-07-30T00:01:53.150208073Z - /home/site/wwwroot/node_modules/jwks-rsa/src/wrappers/cache.js
2024-07-30T00:01:53.150211073Z - /home/site/wwwroot/node_modules/jwks-rsa/src/wrappers/index.js
2024-07-30T00:01:53.150221573Z - /home/site/wwwroot/node_modules/jwks-rsa/src/JwksClient.js
2024-07-30T00:01:53.150224673Z - /home/site/wwwroot/node_modules/jwks-rsa/src/index.js
2024-07-30T00:01:53.150227673Z - /home/site/wwwroot/src/v1/middlewares/jwt.js
2024-07-30T00:01:53.150230673Z - /home/site/wwwroot/app.js
2024-07-30T00:01:53.150233773Z - /home/site/wwwroot/src/v1/bin/www
2024-07-30T00:01:53.150236873Z     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2024-07-30T00:01:53.150240173Z     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2024-07-30T00:01:53.150243273Z     at Module.require (node:internal/modules/cjs/loader:1005:19)
2024-07-30T00:01:53.150246473Z     at Module.patchedRequire (/agents/nodejs/node_modules/diagnostic-channel/dist/src/patchRequire.js:16:46)
2024-07-30T00:01:53.150249473Z     at Module.Hook._require.Module.require (/agents/nodejs/node_modules/require-in-the-middle/index.js:167:34)
2024-07-30T00:01:53.150252573Z     at require (node:internal/modules/cjs/helpers:102:18)
2024-07-30T00:01:53.150255473Z     at Object.<anonymous> (/home/site/wwwroot/node_modules/lru-memoizer/node_modules/lru-cache/lib/lru-cache.js:5:11)
2024-07-30T00:01:53.150259073Z     at Module._compile (node:internal/modules/cjs/loader:1103:14)
2024-07-30T00:01:53.150261973Z     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
2024-07-30T00:01:53.150276373Z     at Module.load (node:internal/modules/cjs/loader:981:32) {
2024-07-30T00:01:53.150279973Z   code: 'MODULE_NOT_FOUND',
2024-07-30T00:01:53.150282973Z   requireStack: [
2024-07-30T00:01:53.150285873Z     '/home/site/wwwroot/node_modules/lru-memoizer/node_modules/lru-cache/lib/lru-cache.js',
2024-07-30T00:01:53.150288973Z     '/home/site/wwwroot/node_modules/lru-memoizer/lib/async.js',
2024-07-30T00:01:53.150291873Z     '/home/site/wwwroot/node_modules/lru-memoizer/lib/index.js',
2024-07-30T00:01:53.150294973Z     '/home/site/wwwroot/node_modules/jwks-rsa/src/wrappers/cache.js',
2024-07-30T00:01:53.150297873Z     '/home/site/wwwroot/node_modules/jwks-rsa/src/wrappers/index.js',
2024-07-30T00:01:53.150300873Z     '/home/site/wwwroot/node_modules/jwks-rsa/src/JwksClient.js',
2024-07-30T00:01:53.150303873Z     '/home/site/wwwroot/node_modules/jwks-rsa/src/index.js',
2024-07-30T00:01:53.150308573Z     '/home/site/wwwroot/src/v1/middlewares/jwt.js',
2024-07-30T00:01:53.150311573Z     '/home/site/wwwroot/app.js',
2024-07-30T00:01:53.150314573Z     '/home/site/wwwroot/src/v1/bin/www'
2024-07-30T00:01:53.150317573Z   ]
2024-07-30T00:01:53.150320473Z }

Reproduction

  1. Install jwks-rsa@3.1.0
  2. Deploy to Azure App Service, Node 20.x LTS

Additional context

Build fails when deploying to an Azure App Service (docker container). The docker command run by deployment:

docker run -d --expose=8080 --name ***_0_e74571c2 -e WEBSITE_USE_DIAGNOSTIC_SERVER=true -e WEBSITE_SITE_NAME=*** -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=***.azurewebsites.net -e WEBSITE_INSTANCE_ID=*** -e HTTP_LOGGING_ENABLED=1 -e NODE_OPTIONS=--require /agents/nodejs/build/src/Loader.js appsvc/node:20-lts_20240619.2.tuxprod npm run start-uat

Downgrading to 3.0.1/3.0.0 did not resolve

jwks-rsa version

3.1.0

Node.js version

20.14.0

kieran-reportabl commented 1 month ago

Workaround found: Open the remote server via Kudu tools/SSH and navigate to www root...

  1. rm -rf node_modules
  2. rm -f package-lock.json
  3. npm install

Honestly unsure where to solve this issue. If a dependency version update here isn't the solution, perhaps best I move this to Azure or lru-memoizer.