Mastra sample code not working

Hey @Abhi Aiyer and @roamin , I realize my response on the last post was a bit late since I was a conference last week and did not have time to reply. I saw that @Abhi Aiyer told me to open a new post. It seem like the sample still has some issues, the RDS instance is connecting now but app itself seem to broken in some ways after you updated the Mastra packages. Here are the two issues I’m seeing: I will breaking this messages in chunks because of discord content window limits, there is more below.
14 Replies
Kevin (Defang)
Kevin (Defang)OP2w ago
1. Octokit appears to be misconfigured (rate limiting too quickly) It seems like Octokit may not be configured correctly, because I’m hitting rate limits after very few requests. The environment variable is being picked up — here’s how Octokit is initialized:
import { Octokit } from "octokit";
export const gh = new Octokit({
auth: process.env.GITHUB_TOKEN!,
});
import { Octokit } from "octokit";
export const gh = new Octokit({
auth: process.env.GITHUB_TOKEN!,
});
Despite that, I still get this error when hosting it on AWS: Request quota exhausted for request GET /repos/{owner}/{repo} I am also getting these warning about octokit which might be related to this issue:
unexpected export *
export * used with module [externals]/node:crypto [external] (node:crypto, cjs) which is a CommonJS module with exports only available at runtime
List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.`

Import trace:
external:
[externals]/node:crypto [external]
./node_modules/.pnpm/@octokit+webhooks-methods@6.0.0/node_modules/@octokit/webhooks-methods/dist-node/index.js [Server Component]
./node_modules/.pnpm/@octokit+webhooks@14.1.3/node_modules/@octokit/webhooks/dist-bundle/index.js [Server Component]
./node_modules/.pnpm/@octokit+app@16.1.2/node_modules/@octokit/app/dist-node/index.js [Server Component]
./node_modules/.pnpm/octokit@5.0.5/node_modules/octokit/dist-bundle/index.js [Server Component]
./src/lib/octokit.ts [Server Component]
./src/mastra/tools/getRepositoryPullRequests.ts [Server Component]
./src/mastra/agent/index.ts [Server Component]
./src/mastra/index.ts [Server Component]
./src/components/custom/AppSidebar.tsx [Server Component]
./src/app/[owner]/[repo]/layout.tsx [Server Component]
unexpected export *
export * used with module [externals]/node:crypto [external] (node:crypto, cjs) which is a CommonJS module with exports only available at runtime
List all export names manually (`export { a, b, c } from "...") or rewrite the module to ESM, to avoid the additional runtime code.`

Import trace:
external:
[externals]/node:crypto [external]
./node_modules/.pnpm/@octokit+webhooks-methods@6.0.0/node_modules/@octokit/webhooks-methods/dist-node/index.js [Server Component]
./node_modules/.pnpm/@octokit+webhooks@14.1.3/node_modules/@octokit/webhooks/dist-bundle/index.js [Server Component]
./node_modules/.pnpm/@octokit+app@16.1.2/node_modules/@octokit/app/dist-node/index.js [Server Component]
./node_modules/.pnpm/octokit@5.0.5/node_modules/octokit/dist-bundle/index.js [Server Component]
./src/lib/octokit.ts [Server Component]
./src/mastra/tools/getRepositoryPullRequests.ts [Server Component]
./src/mastra/agent/index.ts [Server Component]
./src/mastra/index.ts [Server Component]
./src/components/custom/AppSidebar.tsx [Server Component]
./src/app/[owner]/[repo]/layout.tsx [Server Component]
2. Next.js redirect When loading the site, I hit a redirect error when running locally. After clicking a repository title, the first request fails with:
Error: NEXT_REDIRECT
at <unknown> (src/actions/listThreadsOrCreateNewThread.ts:43:17)
41 | metadata: { owner, repo },
42 | });
> 43 | redirect(`/${owner}/${repo}/${thread?.id}`);
| ^
44 | } catch (error) {
45 | console.error(error);
46 | throw new Error("Could not create thread"); {
digest: 'NEXT_REDIRECT;push;/mastra-ai/mastra/eff5f32d-7fe1-4eda-9966-3d2cf95b0157;307;'
}
Action error: Could not create thread
POST / 200 in 470ms (compile: 9ms, render: 461ms)
Error: NEXT_REDIRECT
at <unknown> (src/actions/listThreadsOrCreateNewThread.ts:43:17)
41 | metadata: { owner, repo },
42 | });
> 43 | redirect(`/${owner}/${repo}/${thread?.id}`);
| ^
44 | } catch (error) {
45 | console.error(error);
46 | throw new Error("Could not create thread"); {
digest: 'NEXT_REDIRECT;push;/mastra-ai/mastra/eff5f32d-7fe1-4eda-9966-3d2cf95b0157;307;'
}
Action error: Could not create thread
POST / 200 in 470ms (compile: 9ms, render: 461ms)
But clicking again makes it work. But the browser goes white with: Application error: a client-side exception has occurred... If I click the refresh the page then it enter the chatbox ui and then work. If I want to chat to another repo then this cycle of troubleshooting start again for any other repo link.
Kevin (Defang)
Kevin (Defang)OP2w ago
No description
Abhi Aiyer
Abhi Aiyer2w ago
Are you using a GITHUB_TOKEN? Authenticated GH requests have higher request quotas The octokit log isn't really an error and being logged by nextjs
Mastra Triager
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10473 🔍 If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly. 🙏 Thank you for helping us improve Mastra!
Abhi Aiyer
Abhi Aiyer2w ago
Found the issues, fixing! Pushed a fix to the repo on main. We had some react issues and some redirect problems. Looks fixed on my end!
Kevin (Defang)
Kevin (Defang)OP2w ago
Yes I have the GITHUB_TOKEN set, I even made another GITHUB_TOKEN on my dummy account and it exhausted the limit on that too. At one point my token got exhausted hosting on AWS, my copilot log me out on my vscode. I had to wait to the next day until my limit reset.
Abhi Aiyer
Abhi Aiyer2w ago
Let me see if i can make it reduce the amount of fetches to GH Alright i pushed another change that makes the initial repo list static, and adjusted some tools. Any other changes please feel free to contribute to repo-base
Kevin (Defang)
Kevin (Defang)OP2w ago
@Abhi Aiyer Please have a look when you have time: https://github.com/mastra-ai/repo-base/pull/1
GitHub
Refactors project structure and streamlines Docker setup by KevyVo ...
Moves application files to a dedicated app directory to introduces a Dockerfile for containerized development. Replaces the old docker-compose.yml with compose.yaml to align with Docker Compose v2 ...
Kevin (Defang)
Kevin (Defang)OP2w ago
When a user runs this project, they only need to provide the GOOGLE_GENERATIVE_AI_API_KEY—either by setting it in a .env file or defining it directly in the Compose file. The Docker Compose setup also includes hot reloading, so the entire stack becomes ready to use with a single command: docker compose up. This brings the project one step closer to being production-ready. And also a toggle for SSL. Please pull the changes and run docker compose up, if you like to test it before considering to merge the PR.
Abhi Aiyer
Abhi Aiyer2w ago
Awesome thank you for this, I will take a look
Kevin (Defang)
Kevin (Defang)OP2w ago
There was not to much changed, as you see most of the non important diff was just moving the code into a new directory call /app. so if you see 77 changed there really only 3 files added, most of it was moving location. I would'nt dump such a big PR on you 😁 .
Abhi Aiyer
Abhi Aiyer2w ago
Merged!
Kevin (Defang)
Kevin (Defang)OP2w ago
Hey @Abhi Aiyer , I realized after deploying to Vercel that the previous directory structure wasn’t compatible with Vercel. I’ve reverted the project back to your original structure, but kept all the Docker-related improvements. This means local Docker development still works seamlessly with hot reloading and user no longer need to do pnpm install since that is handle by the dockerfile. The project is now properly aligned with Vercel’s deployment requirements. Sorry for the back and forth and taking up your valuable time. I only realize this after deploying to Vercel. Anyways this fix would only benefit Mastra users. PR: https://github.com/mastra-ai/repo-base/pull/2 Please approve when you have time, it only a small PR with a diff of 10 lines. Most it was just moving the files out to be Vercel friendly. If you like to confirm the working state, please pull the branch and run docker compose up.
Abhi Aiyer
Abhi Aiyer2w ago
Merged!

Did you find this page helpful?