express-basic-auth
express-basic-auth copied to clipboard
TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received undefined
Migrating an application from Node 16 to Node 18, running the app tests - they fail with this:
TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received undefined at new NodeError (node:internal/errors:393:5) at Function.byteLength (node:buffer:740:11) at safeCompare (/Users/username/IdeaProjects/project/node_modules/express-basic-auth/index.js:9:33) at staticUsersAuthorizer (/Users/username/IdeaProjects/project/node_modules/express-basic-auth/index.js:42:43) at authMiddleware (/Users/username/IdeaProjects/project/node_modules/express-basic-auth/index.js:61:18) at Layer.handle [as handle_request] (/Users/username/IdeaProjects/project/node_modules/express/lib/router/layer.js:95:5) at next (/Users/username/IdeaProjects/project/node_modules/express/lib/router/route.js:144:13) at Route.dispatch (/Users/username/IdeaProjects/project/node_modules/express/lib/router/route.js:114:3) at Layer.handle [as handle_request] (/Users/username/IdeaProjects/project/node_modules/express/lib/router/layer.js:95:5) at /Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:284:15 at Function.process_params (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:346:12) at next (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:280:10) at expressInit (/Users/username/IdeaProjects/project/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/Users/username/IdeaProjects/project/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:328:13) at /Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:286:9 at Function.process_params (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:346:12) at next (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:280:10) at query (/Users/username/IdeaProjects/project/node_modules/express/lib/middleware/query.js:45:5) at Layer.handle [as handle_request] (/Users/username/IdeaProjects/project/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:328:13) at /Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:286:9 at Function.process_params (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:346:12) at next (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:280:10) at Function.handle (/Users/username/IdeaProjects/project/node_modules/express/lib/router/index.js:175:3) at Function.handle (/Users/username/IdeaProjects/project/node_modules/express/lib/application.js:181:10) at Server.app (/Users/username/IdeaProjects/project/node_modules/express/lib/express.js:39:9) at Server.emit (node:events:513:28) at parserOnIncoming (node:_http_server:1068:12) at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
Still looking to find the root cause.
Follow
For me, tests run under Node 18.18 - can you give me more details to reproduce?
Observed this error with an empty users
config. eg:
const auth = {
challenge: true,
users: {
[null]: null
}
}
My fix was... adding credentials 🗡️