Multiple @ark registries detected
I'm receiving this error in a Nextjs app:
I use it in my project once:
Ideas?
Version: 2.0.0-rc.15
16 Replies
I have actually two errors related to arktype in Nodejs
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 placeIs it working and you get a warning, or is it broken? There's nothing I can really do internally to resolve this
Is there a way to detect if the current module is ESM or CJS loaded?
If yes please do that
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.
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
Hmm
What actually happens if there are multiple registries?
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
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
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
If only there were import traces
True that would be very useful
For circularities as well
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:
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 nextI did get that error for every worker thread before
Sure but that's essentially like once per process? One log message per process doesn't seem like very much
okay thanks, I'll come back to this later, planning to push to production next week.