Open suryavirkapur opened 5 days ago
What is the code that produces this? How can I reproduce it?
Followed development intructions on README.md: clone repo, switch .env.development to .env.local, and then run the project.
http://localhost:8101/handler/sign-in
Login via Email Magic Link
stackframe/stack-backend:dev: [dev] [ ERR] [xfjenwzm9aqkbsvx] POST http://localhost:8102/api/v1/auth/otp/sign-in: Internal Server Error. The error message follows, but will be stripped in production. TypeError: Cannot read properties of undefined (reading '0')
@stackframe/stack-backend:dev: [dev] at isInsideNodeModules (node:internal/util:511:17)
@stackframe/stack-backend:dev: [dev] at showFlaggedDeprecation (node:buffer:178:8)
@stackframe/stack-backend:dev: [dev] at new Buffer (node:buffer:266:3)
@stackframe/stack-backend:dev: [dev] at BN.toArrayLike (webpack-internal:///(rsc)/../../node_modules/.pnpm/bn.js@4.12.0/node_modules/bn.js/lib/bn.js:546:15)
@stackframe/stack-backend:dev: [dev] at BN.toBuffer (webpack-internal:///(rsc)/../../node_modules/.pnpm/bn.js@4.12.0/node_modules/bn.js/lib/bn.js:531:17)
@stackframe/stack-backend:dev: [dev] at getPrivateJwk (webpack-internal:///(rsc)/../../packages/stack-shared/dist/utils/jwt.js:90:85)
@stackframe/stack-backend:dev: [dev] at async signJWT (webpack-internal:///(rsc)/../../packages/stack-shared/dist/utils/jwt.js:59:74)
@stackframe/stack-backend:dev: [dev] at async generateAccessToken (webpack-internal:///(rsc)/./src/lib/tokens.tsx:100:16)
@stackframe/stack-backend:dev: [dev] at async createAuthTokens (webpack-internal:///(rsc)/./src/lib/tokens.tsx:113:25)```
Broswer Console Dump:
https://pastebin.com/6DpbapPY
Followed development intructions on README.md: clone repo, switch .env.development to .env.local, and then run the project.
http://localhost:8101/handler/sign-in
Login via Email Magic Link
stackframe/stack-backend:dev: [dev] [ ERR] [xfjenwzm9aqkbsvx] POST http://localhost:8102/api/v1/auth/otp/sign-in: Internal Server Error. The error message follows, but will be stripped in production. TypeError: Cannot read properties of undefined (reading '0') @stackframe/stack-backend:dev: [dev] at isInsideNodeModules (node:internal/util:511:17) @stackframe/stack-backend:dev: [dev] at showFlaggedDeprecation (node:buffer:178:8) @stackframe/stack-backend:dev: [dev] at new Buffer (node:buffer:266:3) @stackframe/stack-backend:dev: [dev] at BN.toArrayLike (webpack-internal:///(rsc)/../../node_modules/.pnpm/bn.js@4.12.0/node_modules/bn.js/lib/bn.js:546:15) @stackframe/stack-backend:dev: [dev] at BN.toBuffer (webpack-internal:///(rsc)/../../node_modules/.pnpm/bn.js@4.12.0/node_modules/bn.js/lib/bn.js:531:17) @stackframe/stack-backend:dev: [dev] at getPrivateJwk (webpack-internal:///(rsc)/../../packages/stack-shared/dist/utils/jwt.js:90:85) @stackframe/stack-backend:dev: [dev] at async signJWT (webpack-internal:///(rsc)/../../packages/stack-shared/dist/utils/jwt.js:59:74) @stackframe/stack-backend:dev: [dev] at async generateAccessToken (webpack-internal:///(rsc)/./src/lib/tokens.tsx:100:16) @stackframe/stack-backend:dev: [dev] at async createAuthTokens (webpack-internal:///(rsc)/./src/lib/tokens.tsx:113:25)``` Broswer Console Dump: https://pastebin.com/6DpbapPY
Are you sure that you didn't create a user with the same email before? I can't reproduce this problem
Just tried singning up with a new email. Same issue.
packages/stack-shared/src/utils/jwt.tsx at Line 35:
issuer: string,
audience: string,
payload: any,
expirationTime?: string,
}) {
const secret = getPerAudienceSecret({ audience: options.audience, secret: STACK_SERVER_SECRET });
const kid = getKid({ secret });
const privateJwk = await jose.importJWK(await getPrivateJwk(secret));
return await new jose.SignJWT(options.payload)
.setProtectedHeader({ alg: "ES256", kid })
.setIssuer(options.issuer)
.setIssuedAt()
.setAudience(options.audience)
.setExpirationTime(options.expirationTime || "5m")
.sign(privateJwk);
}
Is returning an await on a promise.
export async function generateAccessToken(options: {
projectId: string,
useLegacyGlobalJWT: boolean,
userId: string,
}) {
waitUntil(logEvent([SystemEventTypes.UserActivity], { projectId: options.projectId, userId: options.userId }));
if (options.useLegacyGlobalJWT) {
return await legacySignGlobalJWT(
jwtIssuer,
{ projectId: options.projectId, sub: options.userId },
getEnvVariable("STACK_ACCESS_TOKEN_EXPIRATION_TIME", "10min")
);
} else {
return await signJWT({
issuer: jwtIssuer,
audience: options.projectId,
payload: { sub: options.userId },
expirationTime: getEnvVariable("STACK_ACCESS_TOKEN_EXPIRATION_TIME", "10min"),
});
}
}
And here there is an await on an await ...
apps/backend/src/lib/tokens.tsx at Line 73:
This is not a function on the hot path, but thought would let you know.
Using the
dev
branch on my Mac.Node and PNPM Versions
Error: