Multiple @ark registries detected

I'm receiving this error in a Nextjs app:
Multiple @ark registries detected. This can lead to unexpected behavior.
Multiple @ark registries detected. This can lead to unexpected behavior.
I use it in my project once:
import { type } from 'arktype'

export const envSchema = type({
moduleId: 'string',
moduleMode: 'string | undefined',
})

export type EnvSchema = typeof envSchema.infer
import { type } from 'arktype'

export const envSchema = type({
moduleId: 'string',
moduleMode: 'string | undefined',
})

export type EnvSchema = typeof envSchema.infer
Ideas? Version: 2.0.0-rc.15
16 Replies
OnkelTem
OnkelTemOP3mo ago
I have actually two errors related to arktype in Nodejs
Multiple @ark registries detected. This can lead to unexpected behavior.
Multiple @ark registries detected. This can lead to unexpected behavior.
File unknown was initialized multiple times, likely due to being imported from both CJS and ESM contexts.
File unknown was initialized multiple times, likely due to being imported from both CJS and ESM contexts.
I.e. the second one is probably also connected Initially I thought that arktype exports both CJS and ESM, but I opened its package.json and it doesn't seem to be the case, I see only ESMs type: module is also in its place
ssalbdivad
ssalbdivad3mo ago
Is it working and you get a warning, or is it broken? There's nothing I can really do internally to resolve this
Dimava
Dimava3mo ago
Is there a way to detect if the current module is ESM or CJS loaded? If yes please do that
Ibnu Rasikh - creatypestudio.co
I'm encountering the same error, although the website remains functional. I'm using Arktype for tRPC in my Next.js projects, and while the API operates smoothly, I'm concerned about the logs. Specifically, I'm worried about the potential storage space consumption these logs might cause on my drive.
ssalbdivad
ssalbdivad2mo ago
Maybe it's an error you could raise with Next.js? I'm surprised it would happen in prod at all as usually the same module being initialized multiple times would be in dev. I would accept a PR with some config option to disable that logging though
Dimava
Dimava2mo ago
Hmm What actually happens if there are multiple registries?
ssalbdivad
ssalbdivad2mo ago
You'd overwrite all your existing cached types. It shouldn't matter much as long as the registry is reinitialized with nothing in it, but fundamentally a module's top-level logic executing twice isn't something that should happen in the language
Dimava
Dimava2mo ago
Hmm It could be useful if it recorded which types did the old instance instantiate and which the new one did So you would at least have something to refer to when trying to understand what's happening
ssalbdivad
ssalbdivad2mo ago
The amount of logic already dedicated to providing specific information about versions etc. in this case is so high I could just ignore it and let people deal with unexpected bugs It's not an arktype-specific assumption that module-level logic should only run once, it would break lots of arbitrary code So it should be on whatever is executing that JS to avoid doing that
Dimava
Dimava2mo ago
If only there were import traces
ssalbdivad
ssalbdivad2mo ago
True that would be very useful For circularities as well
Ibnu Rasikh - creatypestudio.co
I'm pretty new to all this stuff and still learning. When you mentioned config options, were you thinking of tsconfig or package.json? Just so you know, I already added "type": "module" in my package.json. and also here's what my tsconfig looks like:
{
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"checkJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,

/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,

/* Bundled projects */
"lib": ["dom", "dom.iterable", "ES2022"],
"noEmit": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "preserve",
"plugins": [{ "name": "next" }],
"incremental": true,
// "exactOptionalPropertyTypes": true,

/* Path Aliases */
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
// "**/*.cjs",
".next/types/**/*.ts",
"types",
"trigger.config.ts",
"src/env.js"
// ".txt"
],
"exclude": ["node_modules", "ecosystem.config.js", "_draft"]
}
{
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"checkJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,

/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,

/* Bundled projects */
"lib": ["dom", "dom.iterable", "ES2022"],
"noEmit": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "preserve",
"plugins": [{ "name": "next" }],
"incremental": true,
// "exactOptionalPropertyTypes": true,

/* Path Aliases */
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
// "**/*.cjs",
".next/types/**/*.ts",
"types",
"trigger.config.ts",
"src/env.js"
// ".txt"
],
"exclude": ["node_modules", "ecosystem.config.js", "_draft"]
}
ssalbdivad
ssalbdivad2mo ago
It would have to be a new config option you'd pass to arktype Honestly, you're probably fine ignoring it anyways I'd expect it would occur at most once (hopefully?) when your project initializes so it shouldn't be that much extra logging If it's happening constantly I'd definitely log a bug with next
Dimava
Dimava2mo ago
I did get that error for every worker thread before
ssalbdivad
ssalbdivad2mo ago
Sure but that's essentially like once per process? One log message per process doesn't seem like very much
Ibnu Rasikh - creatypestudio.co
okay thanks, I'll come back to this later, planning to push to production next week.
Want results from more Discord servers?
Add your server