New NodeError (looping error)

I sometimes get this error over and over again in a loop, and can't figure out what's causing it. Anyone else seen this?
at new NodeError (node:internal/errors:393:5)
at Function.fail (node:internal/assert:20:9)
at handleMaxCallStackSize (node:internal/util/inspect:1550:10)
at formatRaw (node:internal/util/inspect:1063:12)
at formatValue (node:internal/util/inspect:841:10)
at formatProperty (node:internal/util/inspect:1920:11)
at formatRaw (node:internal/util/inspect:1055:9)
at formatValue (node:internal/util/inspect:841:10)
at inspect (node:internal/util/inspect:365:10)
at proxy.<computed> (/Users/brenner/repos/avatar-studio/node_modules/@prisma/client/runtime/index.js:33565:12)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at new NodeError (node:internal/errors:393:5)
at Function.fail (node:internal/assert:20:9)
at handleMaxCallStackSize (node:internal/util/inspect:1550:10)
at formatRaw (node:internal/util/inspect:1063:12)
at formatValue (node:internal/util/inspect:841:10)
at formatProperty (node:internal/util/inspect:1920:11)
at formatRaw (node:internal/util/inspect:1055:9)
at formatValue (node:internal/util/inspect:841:10)
at inspect (node:internal/util/inspect:365:10)
at proxy.<computed> (/Users/brenner/repos/avatar-studio/node_modules/@prisma/client/runtime/index.js:33565:12)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
1 Reply
Brenner
Brenner16mo ago
This is happening when I add code to my trpc code. as an example:
import { getAccessToken } from '@privy-io/react-auth'
import { httpBatchLink, loggerLink, TRPCClientError } from '@trpc/client'
import { createTRPCNext } from '@trpc/next'
import { type inferRouterInputs, type inferRouterOutputs } from '@trpc/server'
import { getNetwork } from '@wagmi/core'
import Router from 'next/router'
import { type AppRouter } from 'server/trpc/router/_app'
import superjson from 'superjson'

const getBaseUrl = () => {
if (typeof window !== 'undefined') return '' // browser should use relative url
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}` // SSR should use vercel url
return `http://localhost:${process.env.PORT ?? 3000}` // dev SSR should use localhost
}

const getSlugs = (): Record<string, string | undefined> => {
if (typeof window === 'undefined') return {}
const path = window.location.pathname

const projectRegex = new RegExp(`project\/([^\/]+)(?:\/|$)`)
const projectslug = path.match(projectRegex)?.[1]

const orgRegex = new RegExp(`org\/([^\/]+)(?:\/|$)`)
const orgslug = path.match(orgRegex)?.[1]

return { projectslug, orgslug }
}

const getChain = (): string => {
if (typeof window === 'undefined') return 'undefined'
const { chain } = getNetwork()
// console.log('chain', chain)
return chain?.network ?? 'undefined'
}

// const getNetwork = async () => {
// if (typeof window === 'undefined') return ''
// const chainId = await window.ethereum.request({ method: 'eth_chainId' })
// return chainId // returns as 0x5
// }

export const trpc = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
async headers() {
const accessToken = await getAccessToken()
const slugs = getSlugs()
const chain = getChain()
// console.log('chain2: ', chain)
// const network = await getNetwork()
return {
Authorization: `Bearer ${accessToken}`,
...slugs,
chain,
}
},
}),
],
queryClientConfig: {
defaultOptions: {
queries: {
retry: (failureCount, error) => {
const rerouteCodes = ['UNAUTHORIZED', 'NOT_FOUND', 'FORBIDDEN']

if (error instanceof TRPCClientError) {
if (rerouteCodes.includes(error.data.code)) Router.push('/')
}

if (error?.name === 'AirtableAuthError') {
// dont retry,
return false
}
// console.log('failureCount', failureCount)
return failureCount < 3
},
},
},
},
}
},
ssr: false,
})

/**
* Inference helper for inputs
* @example type HelloInput = RouterInputs['example']['hello']
**/
export type RouterInputs = inferRouterInputs<AppRouter>
/**
* Inference helper for outputs
* @example type HelloOutput = RouterOutputs['example']['hello']
**/
export type RouterOutputs = inferRouterOutputs<AppRouter>
import { getAccessToken } from '@privy-io/react-auth'
import { httpBatchLink, loggerLink, TRPCClientError } from '@trpc/client'
import { createTRPCNext } from '@trpc/next'
import { type inferRouterInputs, type inferRouterOutputs } from '@trpc/server'
import { getNetwork } from '@wagmi/core'
import Router from 'next/router'
import { type AppRouter } from 'server/trpc/router/_app'
import superjson from 'superjson'

const getBaseUrl = () => {
if (typeof window !== 'undefined') return '' // browser should use relative url
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}` // SSR should use vercel url
return `http://localhost:${process.env.PORT ?? 3000}` // dev SSR should use localhost
}

const getSlugs = (): Record<string, string | undefined> => {
if (typeof window === 'undefined') return {}
const path = window.location.pathname

const projectRegex = new RegExp(`project\/([^\/]+)(?:\/|$)`)
const projectslug = path.match(projectRegex)?.[1]

const orgRegex = new RegExp(`org\/([^\/]+)(?:\/|$)`)
const orgslug = path.match(orgRegex)?.[1]

return { projectslug, orgslug }
}

const getChain = (): string => {
if (typeof window === 'undefined') return 'undefined'
const { chain } = getNetwork()
// console.log('chain', chain)
return chain?.network ?? 'undefined'
}

// const getNetwork = async () => {
// if (typeof window === 'undefined') return ''
// const chainId = await window.ethereum.request({ method: 'eth_chainId' })
// return chainId // returns as 0x5
// }

export const trpc = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
async headers() {
const accessToken = await getAccessToken()
const slugs = getSlugs()
const chain = getChain()
// console.log('chain2: ', chain)
// const network = await getNetwork()
return {
Authorization: `Bearer ${accessToken}`,
...slugs,
chain,
}
},
}),
],
queryClientConfig: {
defaultOptions: {
queries: {
retry: (failureCount, error) => {
const rerouteCodes = ['UNAUTHORIZED', 'NOT_FOUND', 'FORBIDDEN']

if (error instanceof TRPCClientError) {
if (rerouteCodes.includes(error.data.code)) Router.push('/')
}

if (error?.name === 'AirtableAuthError') {
// dont retry,
return false
}
// console.log('failureCount', failureCount)
return failureCount < 3
},
},
},
},
}
},
ssr: false,
})

/**
* Inference helper for inputs
* @example type HelloInput = RouterInputs['example']['hello']
**/
export type RouterInputs = inferRouterInputs<AppRouter>
/**
* Inference helper for outputs
* @example type HelloOutput = RouterOutputs['example']['hello']
**/
export type RouterOutputs = inferRouterOutputs<AppRouter>
this code is causing a problem:
if (error?.name === 'AirtableAuthError') {
// dont retry,
return false
}
if (error?.name === 'AirtableAuthError') {
// dont retry,
return false
}
adding that code freezes my entire app