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

ERR_INVALID_ARG_TYPE on the /redirect #30

Closed
rwrife opened this issue Nov 19, 2021 · 5 comments
Closed

ERR_INVALID_ARG_TYPE on the /redirect #30

rwrife opened this issue Nov 19, 2021 · 5 comments

Comments

@rwrife
Copy link

rwrife commented Nov 19, 2021

I've got a basic app setup and when AAD goes to redirect back to my site I'm getting [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
at new NodeError (node:internal/errors:371:5)
at Function.from (node:buffer:321:9)
at _callee$ (C:\Projects\myproject\node_modules\microsoft-identity-express\src\client\webapp\MsalWebAppAuthClient.ts:184:139)

any ideas?

@derisen
Copy link
Contributor

derisen commented May 2, 2022

Hi @rwrife, apologies for the very late response. Looks like there was an issue when accessing the req.session.key (which internally is used for encrypting/decrypting the state parameter). I can't come up with anything off the top of my head other than somehow your express session is not properly properly set up. Can you confirm that?

And sorry for the cryptic error message, but we are picking up this project again and we will work on adding better error logging for such issues.

@hnougher
Copy link

hnougher commented Jun 27, 2022

I can get the same thing with more detail.

Good hint on something in express session.
The easiest temporary solution for me seems to be to set cookie.secure=false even though that is not recommended.

node:internal/errors:465
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at Function.from (node:buffer:323:9)
    at _callee$ (/app/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:1556:127)
    at tryCatch (/app/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:167:40)
    at Generator.invoke [as _invoke] (/app/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:398:22)
    at Generator.next (/app/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:223:21)
    at asyncGeneratorStep (/app/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:18:24)
    at _next (/app/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:40:9)
    at /app/node_modules/microsoft-identity-express/dist/microsoft-identity-express.cjs.development.js:47:7
    at new Promise (<anonymous>) {
  code: 'ERR_INVALID_ARG_TYPE'
}

@derisen
Copy link
Contributor

derisen commented Jul 4, 2022

@hnougher apologies for late response. Thanks for the debug. cookie.secure should be false if the app is running on http, but are you saying you run into this even when running the app on a https connection?

@hnougher
Copy link

hnougher commented Jul 5, 2022

@derisen That is correct.
It was annoyingly working fine in development (http localhost etc) and breaking for production (https only).

@derisen
Copy link
Contributor

derisen commented Oct 12, 2022

Closing as completed.

@derisen derisen closed this as completed Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants