Next.js Discord

Discord Forum

Recompiling in dev being weird

Unanswered
American Chinchilla posted this in #help-forum
Open in Discord
American ChinchillaOP
Since updating to 13.5, the dev environment has been quite difficult to work with for me.

I'm working on a simple search bar right now, where the user typing in the search bar calls fetches from an API route to get search recommendations based on pattern matching in my database. Whenever I edit either the search bar component, or the API route, the API route breaks entirely and I'm unable to use it until I restart the environment, delete the .next directory, and relaunch.

Has anyone encountered this issue before? If so, were you able to fix it?

52 Replies

@DirtyCajunRice | AppDir pages or app dir
American ChinchillaOP
App dir
@American Chinchilla App dir
ayyy i can help on one for once haha
Whats your setup look like
what os
what ide
etc
can you do a next info output?
npx next info
American ChinchillaOP
Yeah just hopped off my laptop give me a sec
@American Chinchilla Yeah just hopped off my laptop give me a sec
well hop back on lets get you sorted lol
@DirtyCajunRice | AppDir `npx next info`
American ChinchillaOP
Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64
Binaries:
  Node: 20.6.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.9.2
Relevant Packages:
  next: 13.5.6
  eslint-config-next: 13.5.6
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A
American ChinchillaOP
i got no clue, i got a next.config.js file
lemme run it locally to compare. sec
American ChinchillaOP
/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = nextConfig


Just default generated config for a js app
ohhhh thats why
just new text saying n a instead of nothing
ok in the next config
try this in next.config.js
experimental: {
  logging: {
    level: 'verbose'
  }
}
then stop next
delete .next.
start
lets see if there are hidden issues
American ChinchillaOP
no issues being logged
requests are just stuck in pending
which requests
can you paste the code as a codeblock?
American ChinchillaOP
route.js
import { getRecommendations } from "@/lib/helpers/api/recommender";
import { NextRequest } from "next/server";

/**
 *
 * @param {NextRequest} req
 * @returns {Response}
 */
export async function GET(req) {
  const { searchParams } = new URL(req.url);
  const recommendations = await getRecommendations(
    searchParams.get("name")
  );
  console.log(recommendations)
  return Response.json(recommendations);
}
getRecommendations just connects to a local db at the moment
American ChinchillaOP
verbose is revealing that it is getting the request, but taking 78-90 seconds
one took 120
might have something to do with the db connection? going to take a look at that
American ChinchillaOP
yeah that was it
just got back
whats up with your db
also, you should use NextResponse (just as a side note)
@DirtyCajunRice | AppDir whats up with your db
American ChinchillaOP
i think it's more the connector library
using mysql2/promise, probably should be mysql-serverless instead
something weird was happening with trying to save the connection as a global variable, ended up getting stuck trying to reuse it
American ChinchillaOP
Yeah it was originally
I modeled the original off the mongo example
oh. nice
so its just being a little asshole
American ChinchillaOP
Yep
Just need to create a new connection every time I want to query 😂
Might look at other libraries lol
no big deal right?
aaahaha